dimanche 27 novembre 2016

decltype(some_vector)::size_type doesn't work as template parameter

Why does this class not compile,

template<class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key>>
class MyContainer
{   
public:
    std::vector<Key, Allocator> data;
    std::vector<std::pair<std::size_t, decltype(data)::size_type>> order;
};

error: type/value mismatch at argument 2 in template parameter list for ‘template struct std::pair’

but that does?

template<class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key>>
class MyContainer
{   
public:
    std::vector<Key, Allocator> data;
    std::vector<std::pair<std::size_t, std::size_t>> order;
};

Aucun commentaire:

Enregistrer un commentaire