C++ - Definition of A Member of A Class Template -


i have template class listmap member called iterator.

template <typename key, typename value, class less = xless<key>> class listmap { public:    class iterator;    //... } 

the definition iterator out of list map follows,

template <typename key, typename value, class less = xless<key>> class listmap<key, value, less>::iterator { //... }    

less template class comparison,

template <typename type> struct xless {    bool operator() (const type& left, const type& right) const {       return left < right;    } }; 

i'm running simple test see whether works, gives me error

cannot add default template argument definition of member of class template

my understanding of template low. why can't use xless in definition of iterator here?

in class declaration listmap provide default last template type (i.e., class less = xless<key>).

in definition of iterator specify default again, remove it.

template <typename key, typename value, class less> //                                      ^^^^^^^^^^ class listmap<key, value, less>::iterator {     //... }   

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -