|
Boost Users : |
Subject: [Boost-users] Problems with nesting boost::container::small_vector and C++98
From: Daniel Trstenjak (daniel.trstenjak_at_[hidden])
Date: 2016-12-31 11:44:02
Hi,
first the used versions:
boost 1.63.0
gcc 5.4.0 20160609
Ubuntu 16.04.1
the example I've problems with is:
#include <map>
#include <boost/container/small_vector.hpp>
using boost::container::small_vector;
typedef std::pair<int, small_vector<float, 8> > mypair;
typedef std::map<int, mypair> mymap;
typedef std::map<int, small_vector<mypair, 8> > mymap2;
typedef std::map<int, small_vector<small_vector<float, 8>, 8> > mymap3;
int main()
{
mymap m;
mypair& sv = m[0];
mymap2 m2;
small_vector<mypair, 8>& sv2 = m2[0];
mymap3 m3;
small_vector<small_vector<float, 8>, 8>& sv3 = m3[0];
}
I can compile it without errors with 'g++ -std=c++11', but without
'-std=c++11' I'm getting an error for the 'operator[]' on mymap2:
dan_at_octa ~> g++ -Iboost_1_63_0/ small_vector_test.cpp
In file included from boost_1_63_0/boost/container/small_vector.hpp:27:0,
from small_vector_test.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<std::pair<int, boost::container::small_vector<float, 8ul> >*, true>; T = std::pair<int, boost::container::small_vector<float, 8ul> >; Allocator = boost::container::small_vector_allocator<boost::container::new_allocator<std::pair<int, boost::container::small_vector<float, 8ul> > > >; 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 = std::pair<int, boost::container::small_vector<float, 8ul> >; long unsigned int N = 8ul; Allocator = boost::container::new_allocator<std::pair<int, boost::container::small_vector<float, 8ul> > >]â
/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<std::pair<int, boost::container::small_vector<float, 8ul> >, 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<std::pair<int, boost::container::small_vector<float, 8ul> >, 8ul>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, boost::container::small_vector<std::pair<int, boost::container::small_vector<float, 8ul> >, 8ul> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = boost::container::small_vector<std::pair<int, boost::container::small_vector<float, 8ul> >, 8ul>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]â
small_vector_test.cpp:18:39: required from here
boost_1_63_0/boost/container/vector.hpp:1261:15: error: binding âconst std::pair<int, boost::container::small_vector<float, 8ul> >â to reference of type âstd::pair<int, boost::container::small_vector<float, 8ul> >&â discards qualifiers
*cur = *first;
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/stl_tree.h:63,
from /usr/include/c++/5/map:60,
from small_vector_test.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:96:12: note: initializing argument 1 of âstd::pair<int, boost::container::small_vector<float, 8ul> >& std::pair<int, boost::container::small_vector<float, 8ul> >::operator=(std::pair<int, boost::container::small_vector<float, 8ul> >&)â
struct pair
^
Any ideas?
Is 'boost:container::small_vector' supposed to work without C++11 support?
Thanks!
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