Guest User

Untitled

a guest
Jul 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <assert.h>
  2. #include <type_traits>
  3.  
  4. template<typename T, typename... Others>
  5. struct splitter{
  6. using Head = T;
  7. template <template <typename...> typename U> using Tail = U<Others...>;
  8. };
  9.  
  10. int main() {
  11. static_assert( true == std::is_same<int, splitter<int, double, int>::Head>::value );
  12.  
  13. using MyType = splitter<int,double,int>;
  14. using one = MyType::Head;
  15. using two = MyType::Tail<splitter>::Head;
  16. using three = MyType::Tail<splitter>::Tail<splitter>::Head;
  17. //using four = MyType::Tail<splitter>::Tail<splitter>::Tail<splitter>::Head;
  18.  
  19. static_assert( true == std::is_same<int, one>::value );
  20. static_assert( true == std::is_same<double, two>::value );
  21. static_assert( true == std::is_same<int, three>::value );
  22.  
  23. static_assert( true == std::is_same<double, splitter<int,double,int>::Tail<splitter>::Head>::value );
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment