Exercice du livre de Abrahams C++ Template Metaprogramming
Bonjour,
Dans le livre de Abrahams, il propose un exo:
write an unary metafunction add_const_ref that returns T if it is a reference type otherwise return T const&.
voila ce que je propose:
Code:
1 2 3 4 5 6 7 8 9
| template<class U>
XXX add_const_ref(){
typedef const U& MyConstRefType;
typedef U& MyRefType;
if(is_same<U,MyRefType>()==0){
return MyConstRefType;
};
}; |
Mais je ne vois pas quoi écrire dans XXX. Je ne vois pas comment déclare le type de renvoie d'une telle fonction add_const_ref().
Je vous remercie.