fork download
  1. #include <iostream>
  2. #include <set>
  3. #include <cmath>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <typeinfo>
  7. #include <map>
  8.  
  9. using namespace std;
  10.  
  11. template<typename... T>
  12. struct collection_traits { using template_type = void; };
  13.  
  14. template<template<typename...> class C, typename... Args>
  15. struct collection_traits<C<Args...> > {
  16. template<typename... Subst>
  17. using template_type = C<Subst...>;
  18. };
  19.  
  20.  
  21. template<typename a, typename b, typename c>
  22. struct A {
  23. using a1 = a;
  24. using b1 = b;
  25. using c1 = c;
  26. };
  27.  
  28. int main(int argc, char *argv[]) {
  29. collection_traits<vector<int>>::template_type<double> t;
  30. collection_traits<map<int, int>>::template_type<string, string> t2;
  31. collection_traits<set<int>>::template_type<double> t3;
  32. collection_traits<A<int, int, int>>::template_type<string, string, string> t4;
  33.  
  34. cout << typeid(t).name() << endl;
  35. cout << typeid(t2).name() << endl;
  36. cout << typeid(t3).name() << endl;
  37. cout << typeid(t4).name() << endl;
  38.  
  39. t.push_back(123.5);
  40. t2["ASD"] = "QWE";
  41. cout << t.front() << endl;
  42.  
  43. for (auto e : t2)
  44. cout << e.first << " " << e.second << endl;
  45.  
  46. }
  47.  
  48.  
  49.  
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
St6vectorIdSaIdEE
St3mapISsSsSt4lessISsESaISt4pairIKSsSsEEE
St3setIdSt4lessIdESaIdEE
1AISsSsSsE
123.5
ASD QWE