dimanche 22 avril 2018

STL algorithm name resolvable or undefined based on template argument deduction utilization

Given this code:

#include  <algorithm>
#include  <vector>

using std::vector;

int main()
{
vector<int> intVec(100, 1);

random_shuffle(intVec.begin(), intVec.end()); //no problem

std::random_shuffle<vector<int>::iterator>(intVec.begin(), intVec.end()); //no problem

random_shuffle<vector<int>::iterator>(intVec.begin(), intVec.end()); //random_shuffle undefined!

return 0;
}

I realize name management in this code is bad. A less minimal codebase inspired my question however. random_shuffle is resolvable with no std qualification. If qualified and explicitly templated, no issue once more. However, if there is no std qualification, AND explicit template arguments(which are implicitly correct in the least), random_shuffle is suddenly undefined. Why?

Visual Studio 2017(I know...if this is MS shenanigans, just say so)

Aucun commentaire:

Enregistrer un commentaire