Voglio creare un costruttore per una classe, utilizzando qualsiasi tipo di integrale, ma distinguere tra firmato e non firmato. Non voglio che questo sia un modello sulla classe stessa. Quanto segue non funziona. Visual Studio sta solo dicendo che nessun argomento corrisponderà.crea un costruttore variadic per le variabili firmate e non firmate utilizzando enable_if
class Thing{
public:
template<typename Integral>
Thing(
typename std::enable_if<
std::is_integral<Integral>::value &&
!std::is_same<Integral,bool>::value &&
std::is_signed<Integral>::value
,Integral
>::type num
){
//constructor using signed variable as input
}
template<typename Integral>
Thing(
typename std::enable_if<
std::is_integral<Integral>::value &&
!std::is_same<Integral,bool>::value &&
!std::is_signed<Integral>::value//notice this is different
,Integral
>::type num
){
//constructor using unsigned variable as input
}
};
Non funziona? Che cosa sta facendo? :) – erip
La mancanza della parola chiave 'public' dice almeno qualcosa riguardo al primo errore che otterrò mentre provo il codice sopra ... – skypjack