I am using SFINAE to detect whether a type has a specific static function defined (e.g. hello_world()
):
template <typename T>
class has_helloworld {
typedef char one;
typedef long two;
template <typename C>
static one test(decltype(&C::hello_world));
template <typename C>
static two test(...);
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
};
Example use:
static_assert(has_helloworld<T>::value,
"Error: Type provided does not have hello_world() function defined");
However, doing it this way detects all of the method, whereas I would like to only detect static functions that are constexpr
. Is that possible?
Aucun commentaire:
Enregistrer un commentaire