Chcę utworzyć konstruktor klasy, używając dowolnego typu integralnego, ale rozróżniając podpisany i unsigned. Nie chcę, aby był to szablon na samej klasie. Poniższe nie działa. Visual Studio mówi tylko, że żadne argumenty nie będą pasować.Tworzenie konstruktora variadic dla zmiennych podpisanych i niepodpisanych przy użyciu 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
}
};
To nie działa? Co to robi? :) – erip
Brak słowa kluczowego "public" mówi co najmniej o pierwszym błędzie, który dostanę próbując kodu powyżej ... – skypjack