fork(14) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. template <typename T> class Bar {};
  5.  
  6. template <typename C> struct get_template_type;
  7.  
  8. template <template <typename > class C, typename T>
  9. struct get_template_type<C<T>>
  10. {
  11. using type = T;
  12. };
  13.  
  14. template <typename T>
  15. void someFunction()
  16. {
  17. std::cout << __PRETTY_FUNCTION__ << std::endl;
  18. }
  19.  
  20. template <typename C>
  21. void test(const C& c)
  22. {
  23. for (auto& foo : c) {
  24. someFunction<typename get_template_type<typename std::decay<decltype(foo)>::type>::type>();
  25. }
  26. }
  27.  
  28. int main() {
  29. std::vector<Bar<int>> fs(1);
  30.  
  31. test(fs);
  32. }
  33.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
void someFunction() [with T = int]