Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <functional>
- using YES = char;
- struct NO { YES m[2]; };
- template<typename T>
- struct Method {};
- template<>
- struct Method<int> {
- void func() {};
- };
- template<typename T>
- struct is_func_defined {
- Method<T> m;
- template<class Z, std::function<void()> = &(m.func)>
- struct wrapper {};
- template<class C>
- static YES check(wrapper<C> * p);
- template<class C>
- static NO check(...);
- static bool const value = sizeof(YES) == sizeof(check<T>(0));
- };
- int main() {
- std::cout << is_func_defined<int>::value << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement