Hi,
typedef std::pair > mypair;
If I'm replacing 'mypair' with 'mystruct':
struct mystruct {
mystruct& operator=(const mystruct& other) {
i = other.i;
sv = other.sv;
return *this;
}
int i;
small_vector sv;
};
Then I can compile it without C++11 support, but I've to
implement the 'operator=' by hand, otherwise I'm still getting
a compile error:
dan@octa ~> g++ -Iboost_1_63_0/ small_vector_test_2.cpp
In file included from boost_1_63_0/boost/container/small_vector.hpp:27:0,
from small_vector_test_2.cpp:2:
boost_1_63_0/boost/container/vector.hpp: In instantiation of ‘void boost::container::vector::assign(FwdIt, FwdIt, typename boost::move_detail::disable_if_or >, boost::move_detail::is_convertible, boost::container::container_detail::is_input_iterator<FwdIt> >::type*) [with FwdIt = boost::container::container_detail::vec_iterator; T = mystruct; Allocator = boost::container::small_vector_allocator; typename boost::move_detail::disable_if_or >, boost::move_detail::is_convertible, boost::container::container_detail::is_input_iterator<FwdIt> >::type = void]’:
boost_1_63_0/boost/container/small_vector.hpp:563:7: required from ‘boost::container::small_vector::small_vector(const boost::container::small_vector&) [with T = mystruct; long unsigned int N = 8ul; Allocator = boost::container::new_allocator<mystruct>]’
/usr/include/c++/5/bits/stl_pair.h:113:31: required from ‘std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = const int; _T2 = boost::container::small_vector]’
/usr/include/c++/5/bits/stl_map.h:487:23: required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = boost::container::small_vector; _Compare = std::less<int>; _Alloc = std::allocator > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = boost::container::small_vector; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]’
small_vector_test_2.cpp:21:41: required from here
boost_1_63_0/boost/container/vector.hpp:1261:15: error: binding ‘const mystruct’ to reference of type ‘mystruct&’ discards qualifiers
*cur = *first;
^
small_vector_test_2.cpp:6:8: note: initializing argument 1 of ‘mystruct& mystruct::operator=(mystruct&)’
For whatever reasons the operator 'mystruct& mystruct::operator=(mystruct&)' is used, with a non const
reference parameter, which can't work in this context.
Looks like a bug? boost? gcc?
Greetings,
Daniel