fork download
  1. #include <algorithm>
  2.  
  3. struct foo { using type = int; };
  4. struct bar { using type = char; };
  5.  
  6. template<typename... Types> struct TypeList {};
  7.  
  8.  
  9. //This and getScript are simplified, in reality the involve messier templates...
  10. template<typename ReturnType>
  11. struct ReqBuilder
  12. {
  13. using proxy = ReturnType(*)(void*, bool);
  14. // ...
  15. };
  16.  
  17. template<typename scriptType>
  18. struct getScript_impl
  19. {
  20. using type = ReqBuilder<typename scriptType::type>;
  21. };
  22. template<typename scriptType>
  23. using getScript = typename getScript_impl<scriptType>::type;
  24.  
  25. /* REPLACING THIS WITH CODE ABOVE
  26. template<typename scriptType>
  27. using getScript = ReqBuilder<typename scriptType::type>;
  28. */
  29.  
  30. template<typename List, template<typename> typename Wrap> struct WrapTypeList_impl {};
  31. template<typename...Ts, template<typename> typename Wrap> struct WrapTypeList_impl<TypeList<Ts...>, Wrap>
  32. {
  33. using type = TypeList<Wrap<Ts>...>;
  34. };
  35. template<typename List, template<typename> typename Wrap>
  36. using WrapTypeList = typename WrapTypeList_impl<List, Wrap>::type;
  37.  
  38.  
  39. using list1 = TypeList<getScript<foo>, getScript<bar>>;
  40. using list2 = TypeList<ReqBuilder<typename foo::type>, ReqBuilder<typename bar::type>>;
  41. using list3 = WrapTypeList<TypeList<foo, bar>, getScript>;
  42.  
  43. int main()
  44. {
  45. constexpr bool A = std::is_same<list1, list2>::value;
  46. constexpr bool B = std::is_same<list1, list3>::value;
  47. constexpr bool C = std::is_same<list2, list3>::value;
  48.  
  49. static_assert(A, "list1 != list2");
  50. static_assert(B, "list1 != list3");
  51. static_assert(C, "list2 != list3");
  52. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty