I guess the title of the question does not make much of a sense, but I hope the problem description will spread the light.
Can someone please explain how on earth this is passing the compilation?
template<typename Cont, typename = std::enable_if<std::is_integral_v<std::string>>>
void print(const Cont& cont)
{
for (const auto it : cont) {
cout << it << " ";
}
cout << endl;
}
int main()
{
std::vector<string> V;
print(V);
}
The original version was:
template<typename Cont, typename = std::enable_if<std::is_integral_v<typename Cont::value_type>>>
I just explicitly put std::string to be sure.
I guess the enable_if should forbid this function to be instantiated at all right??
What am I missing here?
Aucun commentaire:
Enregistrer un commentaire