Come posso fornire una funzione membro aggiuntiva per template specializzati in modo non in linea? cioèSpecializzazione in template C++ per fornire funzionalità extra membro?
template<typename T>
class sets
{
void insert(const int& key, const T& val);
};
template<>
class sets<bool>
{
void insert(const int& key, const bool& val);
void insert(const int& key){ insert(key, true); };
};
Ma quando scrivo sets<bool>::insert(const int& key)
come
template<>
class sets<bool>
{
void insert(const int& key, const bool& val);
void insert(const int& key);
};
template<>
void sets<bool>::insert(const int& key)
{
insert(key, true);
}
GCC si lamenta:
template-id 'inserire <>' per ' ip_set vuoto :: inserire (const int &) "fa non corrisponde ad alcuna dichiarazione modello