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> {
- int operator()() { return 1; }
- };
- template<class T>
- struct is_brackets_op_defined {
- static void Check(...);
- template<typename C>
- static decltype(Method<C>::()) Check(const C&);
- using type = decltype(Check(
- std::declval< Method<T> >()
- ));
- constexpr static bool value =
- !std::is_same<void, type>();
- };
- int main() {
- std::cout << is_brackets_op_defined<float>::value << std::endl;
- }
Add Comment
Please, Sign In to add comment