https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84283
Bug ID: 84283 Summary: std::map::insert(const_iterator, P&&) now ambiguous with std::map::insert(InputIterator, InputIterator) Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <map> template<typename T> struct map_type_to_map #ifndef FIX : std::map<T, std::map<int, int>> #endif { void add( const std::map<int, int>& values ) { std::map<int, int> m, n; m.insert(n.cbegin(), n.cend()); } }; This fails to compile with trunk (unless FIX is defined): map.cc: In member function ‘void map_type_to_map<T>::add(const std::map<int, int>&)’: map.cc:11:38: error: call of overloaded ‘insert(std::map<int, int>::const_iterator, std::map<int, int>::const_iterator)’ is ambiguous m.insert(n.cbegin(), n.cend()); ^ In file included from /home/jwakely/gcc/8/include/c++/8.0.1/map:61, from map.cc:1: /home/jwakely/gcc/8/include/c++/8.0.1/bits/stl_map.h:876:2: note: candidate: ‘std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator, _Pair&&) [with _Pair = std::_Rb_tree_const_iterator<std::pair<const int, int> >; <template-parameter-2-2> = <missing>; _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]’ insert(const_iterator __position, _Pair&& __x) ^~~~~~ /home/jwakely/gcc/8/include/c++/8.0.1/bits/stl_map.h:892:2: note: candidate: ‘void std::map<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = std::_Rb_tree_const_iterator<std::pair<const int, int> >; _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]’ insert(_InputIterator __first, _InputIterator __last) ^~~~~~ The use of std::enable_if as a default template argument now causes an ambiguity, where it didn't previously. Also here: https://bugzilla.redhat.com/show_bug.cgi?id=1542254