fork download
  1. #include <tuple>
  2.  
  3.  
  4. template<template<typename...> class T, typename>
  5. struct instantiate_with_arg_pack { };
  6.  
  7. template< template<typename...> class T
  8. , template<typename...> class U
  9. , typename... Ts>
  10. struct instantiate_with_arg_pack<T, U<Ts...>>
  11. {
  12. using type = T<Ts...>;
  13. };
  14.  
  15. template<class T>
  16. using to_tuple = typename instantiate_with_arg_pack<std::tuple, T>::type;
  17.  
  18.  
  19. template<typename T = int, typename U = double> struct exampl {};
  20.  
  21.  
  22. template<typename T> struct TD;
  23.  
  24.  
  25. int main()
  26. {
  27. using Tuple = to_tuple<exampl<>>;
  28. TD< exampl<std::tuple_element_t<1, Tuple>, std::tuple_element_t<0, Tuple>> > td; // should swap default template parameters
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:28:82: error: aggregate 'TD<exampl<double, int> > td' has incomplete type and cannot be defined
     TD< exampl<std::tuple_element_t<1, Tuple>, std::tuple_element_t<0, Tuple>> > td; // should swap default template parameters
                                                                                  ^
stdout
Standard output is empty