fork download
  1.  
  2. template < typename T > // T is a type
  3. typename T::value_type // T::value_type is a type
  4. front( T& c )
  5. { return c.front() ; } // T has a member 'front' which is callable
  6.  
  7. struct A
  8. {
  9. using value_type = const int* ;
  10. value_type front() const { return &value ; }
  11. int value = 8 ;
  12. };
  13.  
  14. #include <vector>
  15. #include <iostream>
  16.  
  17. int main ()
  18. {
  19. std::vector<int> cntr { 1234, -7, 345, 6789 } ;
  20. std::cout << front(cntr) << '\n' ; // T => std::vector<int>, T::value_type => int
  21.  
  22. A a ;
  23. std::cout << front(a) << '\n' ; // T => A, T::value_type => const int*
  24. }
  25.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
1234
0xbfddba3c