lundi 30 novembre 2020

Question about template's value_type usage in Stroustrup's book example

In Stroustrup's "A Tour of C++" there is a code snippet

template<typename C>
using Value_type = typename C::value_type;  // the type of C’s elements

template<typename Container>
void algo(Container& c)
{
    /* (1) */ 
    Vector<Value_type<Container>> vec;  // keep results here
    // ...
}

Why we need this using, how it differs from writing in (1) just

Vector<Container::value_type> vec;

Aucun commentaire:

Enregistrer un commentaire