Let's imagine I want to make a templated function that returns the first element of any stl container. The general way would be :
template<typename Container>
Container::value_type first(Container c){
return *(c.begin());
}
This works for vectors, lists, deques, sets and so on.
However, for pair associative containers (std::map), if would like to have
return c.begin()->second;
How could I test (in the function or with template specialization) if I have an pair associative container ?
STL container seem to have no traits attached to it. Is it possible to check if it has a ::key_type ?