I have a template function which performs certain actions depending on the type provided:
template<typename T>
T read()
{
if (std::is_integral<T>()) {
return static_cast<T>(std::stoi(readToken()));
}
else if (std::is_same<T, float>()) {
return std::stof(readToken());
}
else throw std::logic_error("Invalid type");
}
However, integer types aren't being recognized. The result is the same when using ::value
.
What am I missing here?
Aucun commentaire:
Enregistrer un commentaire