Search code examples
c++gccsetc++17template-argument-deduction

Why does deduction fail for std::set in GCC?


I have a std::set which allows deduction from an iterator range.

#include <iostream>
#include <set>

int main() 
{
   std::set s1 = {1,2,3,4}; 
   std::set s2(s1.begin(), s1.end());
}

The above program failed to compile in GCC.

Why does deduction fail for std::set here?


Solution

  • Just take the current GCC version (8.0.0 at this time) and it will build. The template deduction guide for std::set just doesn't seem to be implemented in the older GCC version's stdlib.