mardi 5 mai 2015

Enable a function template in C++ whenever an expression is undefined

Can a function template be enabled whenever some expression is undefined (e.g., xof type t is not streamable to std::cout). Something like

template<typename t>
auto f(const t &x) 
  -> typename enable_if_undefined<decltype(std::cout << x)>::type;

Using SFINAE, I only see how to enable if the expression is defined, but not how to do it if the expression is undefined.

Aucun commentaire:

Enregistrer un commentaire