Qui si stanno miscelando due approcci diversi. La prima è quella suggerita dal @KerrekSB
template<typename T, bool B = is_fundamental<T>::value>
class class_name;
// NOTE: template<> is needed here because this is an explicit specialization of a class template
template<>
class class_name<string, false>{
public:
static string const value;
};
// NOTE: no template<> here, because this is just a definition of an ordinary class member
// (i.e. of the class class_name<string, false>)
string const class_name<string, false>::value = "Str";
In alternativa, si potrebbe completa scrivere il modello generale di classe e specializzarsi in modo esplicito il membro statico per <string, false>
template<typename T, bool B = is_fundamental<T>::value>
class class_name {
public:
static string const value;
};
// NOTE: template<> is needed here because this is an explicit specialization of a class template member
template<>
string const class_name<string, false>::value = "Str";
lasciare fuori il 'template <>' in la definizione di "valore". –
@KerrekSB Grazie mille ! –
@KerrekSB Una risposta del genere non dovrebbe mai diventare "risposta"? Sto cercando di capire cosa dovremmo/non dovremmo fare quando rispondiamo a qualcosa in un commento. – JaredC