Dukales

concatenate

May 29th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <typeinfo>
  3.  
  4. #include <cstdlib>
  5. #include <cassert>
  6.  
  7. #include <cxxabi.h>
  8.  
  9. template< typename ...types >
  10. struct V // implementation
  11. {
  12.    
  13.     using type = V;
  14.    
  15. };
  16.  
  17. template< typename ...first, typename ...second, typename ...rest >
  18. struct V< V< first... >, V< second... >, rest... >
  19.     : V< V< first..., second... >, rest... >
  20. {
  21.  
  22. };
  23.  
  24. template< typename first, typename ...second, typename ...rest >
  25. struct V< first, V< second... >, rest... >
  26.     : V< V< first, second... >, rest... >
  27. {
  28.  
  29. };
  30.  
  31. template< typename ...first, typename second, typename ...rest >
  32. struct V< V< first... >, second, rest... >
  33.     : V< V< first..., second >, rest... >
  34. {
  35.  
  36. };
  37.  
  38. template< typename ...types >
  39. struct V< V< types... > >
  40.     : V< types... >
  41. {
  42.  
  43. };
  44.  
  45. template< int i >
  46. struct T
  47. {
  48.    
  49. };
  50.  
  51. int
  52. main()
  53. {
  54.     auto name = typeid(typename V< T< 0 >, V< T< 1 >, T< 2 > >, T< 3 >, T< 4 >, V< T< 5 >, T< 6 > >, V< T< 7 >, T< 8 > >, T< 9 > >::type).name();
  55.     int status = -4;
  56.     char * demangled_name = abi::__cxa_demangle(name, nullptr, nullptr, &status);
  57.     assert(!(status < 0));
  58.     std::cout << demangled_name << std::endl;
  59.     std::free(demangled_name);
  60.     return EXIT_SUCCESS;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment