Guest User

Untitled

a guest
Dec 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. using YES = char;
  5. struct NO { YES m[2]; };
  6.  
  7. template<typename T>
  8. struct Method {};
  9.  
  10. template<>
  11. struct Method<int> {
  12. int operator()() { return 1; }
  13. };
  14.  
  15. template<class T>
  16. struct is_brackets_op_defined {
  17. static void Check(...);
  18.  
  19. template<typename C>
  20. static decltype(Method<C>::()) Check(const C&);
  21.  
  22. using type = decltype(Check(
  23. std::declval< Method<T> >()
  24. ));
  25.  
  26. constexpr static bool value =
  27. !std::is_same<void, type>();
  28. };
  29.  
  30. int main() {
  31. std::cout << is_brackets_op_defined<float>::value << std::endl;
  32. }
Add Comment
Please, Sign In to add comment