vendredi 6 mars 2015

C++: template to check if expression compiles


When writing template specialization with SFINAE you often come to the point where you need to write a whole new specialization because of one small not-existing member or function. I would like to pack this selection into a small statement like orElse<T a,T b>.


small example:



template<typename T> int get(T& v){
return orElse<v.get(),0>();
}


is this possible?




Aucun commentaire:

Enregistrer un commentaire