|
Boost Users : |
Subject: Re: [Boost-users] Problems with nesting boost::container::small_vector and C++98
From: Daniel Trstenjak (daniel.trstenjak_at_[hidden])
Date: 2017-01-01 08:25:39
Hi,
> typedef std::pair<int, small_vector<float, 8> > 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<float, 8> 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_at_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<T, Allocator>::assign(FwdIt, FwdIt, typename boost::move_detail::disable_if_or<void, boost::move_detail::is_same<typename boost::container::container_detail::version<Allocator>::type, boost::move_detail::integral_constant<unsigned int, 0u> >, boost::move_detail::is_convertible<InIt, typename boost::container::allocator_traits<Allocator>::size_type>, boost::container::container_detail::is_input_iterator<FwdIt> >::type*) [with FwdIt = boost::container::container_detail::vec_iterator<mystruct*, true>; T = mystruct; Allocator = boost::container::small_vector_allocator<boost::container::new_allocator<mystruct> >; typename boost::move_detail::disable_if_or<void, boost::move_detail::is_same<typename boost::container::container_detail::version<Allocator>::type, boost::move_detail::integral_constant<unsigned int, 0u> >, boost::move_detail::is_convertible<InIt, typename boost::container::allocator_traits<Allocator>::size_type>, 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<T, N, Allocator>::small_vector(const boost::container::small_vector<T, N, Allocator>&) [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<mystruct, 8ul>]â
/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<mystruct, 8ul>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, boost::container::small_vector<mystruct, 8ul> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = boost::container::small_vector<mystruct, 8ul>; 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net