samedi 1 avril 2017

template specialization for all iterators of std::map

I have traits class, saying:

template <class T>
struct KeyValueTraits
{
    typedef typename T::key_t key_t;
    typedef typename T::value_t value_t;
}

Now I would like to declare specialization of this traits for all iterators of std::map

template < typename... Args >
struct KeyValueTraits<typename std::map<Args...>::iterator >
{
    typedef std::map<Args...> target_t;
    typedef typename target_t::key_type key_t;
    typedef typename target_t::value_type value_t;
};

Compiler raises an error:

error C2764: 'Args': template parameter not used or deducible in partial specialization

So how to declare traits-type for all possible std::map<...>::iterator?

Aucun commentaire:

Enregistrer un commentaire