template < typename T > // T is a type
typename T::value_type // T::value_type is a type
front( T& c )
{ return c.front() ; } // T has a member 'front' which is callable
struct A
{
using value_type = const int* ;
value_type front() const { return &value ; }
int value = 8 ;
};
#include <vector>
#include <iostream>
int main ()
{
std::vector<int> cntr { 1234, -7, 345, 6789 } ;
std::cout << front(cntr) << '\n' ; // T => std::vector<int>, T::value_type => int
A a ;
std::cout << front(a) << '\n' ; // T => A, T::value_type => const int*
}
CnRlbXBsYXRlIDwgdHlwZW5hbWUgVCA+IC8vIFQgaXMgYSB0eXBlCiAgICB0eXBlbmFtZSBUOjp2YWx1ZV90eXBlIC8vIFQ6OnZhbHVlX3R5cGUgaXMgYSB0eXBlCiAgICAgICAgZnJvbnQoIFQmIGMgKQogICAgICAgICAgICB7IHJldHVybiBjLmZyb250KCkgOyB9IC8vIFQgaGFzIGEgbWVtYmVyICdmcm9udCcgd2hpY2ggaXMgY2FsbGFibGUKCnN0cnVjdCBBCnsKICAgIHVzaW5nIHZhbHVlX3R5cGUgPSBjb25zdCBpbnQqIDsKICAgIHZhbHVlX3R5cGUgZnJvbnQoKSBjb25zdCB7IHJldHVybiAmdmFsdWUgOyB9CiAgICBpbnQgdmFsdWUgPSA4IDsKfTsKCiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCmludCBtYWluICgpCnsKICAgIHN0ZDo6dmVjdG9yPGludD4gY250ciB7IDEyMzQsIC03LCAzNDUsIDY3ODkgfSA7CiAgICBzdGQ6OmNvdXQgPDwgZnJvbnQoY250cikgPDwgJ1xuJyA7IC8vIFQgPT4gc3RkOjp2ZWN0b3I8aW50PiwgVDo6dmFsdWVfdHlwZSA9PiBpbnQKCiAgICBBIGEgOwogICAgc3RkOjpjb3V0IDw8IGZyb250KGEpIDw8ICdcbicgOyAvLyBUID0+IEEsIFQ6OnZhbHVlX3R5cGUgPT4gY29uc3QgaW50Kgp9Cg==