Dear all, I encounter a compile error when using GCC 8 20180204 with a simple C++ program which worked before. Even with GCC 8 20170923. I would like to understand, why this does not compile anymore, and how to fix it. test-map.cc: In member function 'void map_type_to_map<IdType>::add(const value_type&)': test-map.cc:34:59: error: call of overloaded 'insert(std::map<int, int>::const_iterator, std::map<int, int>::const_iterator)' is ambiguous current_values.insert(values.begin(), values.end()); ^ In file included from /home/wesarg/opt/gcc-8-20180204/include/c++/8.0.1/map:61, from test-map.cc:1: /home/wesarg/opt/gcc-8-20180204/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/wesarg/opt/gcc-8-20180204/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) ^~~~~~ Thanks. Best, Bert
#include <map> class map_int_to_map : private std::map<int, std::map<int, int>> { public: using value_type = std::map<int, int>; using base_type = std::map<int, value_type>; map_int_to_map() : base_type() {} ~map_int_to_map() {} inline void add( const value_type& values ) { value_type current_values; current_values.insert( values.begin(), values.end() ); } }; template<typename IdType> class map_type_to_map : private std::map<IdType, std::map<int, int>> { public: using value_type = std::map<int, int>; using base_type = std::map<IdType, value_type>; map_type_to_map() : base_type() {} ~map_type_to_map() {} inline void add( const value_type& values ) { value_type current_values; current_values.insert(values.begin(), values.end()); } };
Attachment:
test-map.err
Description: Binary data
Attachment:
test-map.i.gz
Description: GNU Zip compressed data