fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <type_traits>
  4.  
  5. //ひとつのメタ関数を受け取る
  6. template <template <typename> class Ty>
  7. struct condition {
  8. template <typename T>
  9. using apply = Ty<T>;
  10. };
  11.  
  12. template<template<typename T, typename U> class aaa, typename bind1st_type>
  13. struct binder
  14. {
  15. template<typename T>
  16. using type = aaa<bind1st_type, T>;
  17. };
  18.  
  19. struct string2 : std::string {};
  20.  
  21. int main()
  22. {
  23. using condition1 = condition<std::is_pointer>;
  24. std::cout << condition1::apply<int>::value << std::endl;
  25. std::cout << condition1::apply<int*>::value << std::endl;
  26.  
  27. using condition2 = condition<binder<std::is_base_of, std::string>::type>;
  28. std::cout << condition2::apply<int>::value << std::endl;
  29. std::cout << condition2::apply<string2>::value << std::endl;
  30. }
  31.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
0
1
0
1