[bimap] initializing from range of pair<T&, U&> elements
Hello, I am trying to initialize a bimap<T, U> with a vector<pair<T&, U&>> (the "vector" part isn't important, any range with elements of type pair<T&, U&> has the same effect), but I'm getting a rather monstrous compiler error. The same initialization works for std::map<T, U>. Here is the code: #include <boost/bimap.hpp> #include <boost/range/begin.hpp> #include <boost/range/end.hpp> #include <vector> #include <map> #include <utility> int main() { int i1, i2; float f1, f2; std::vector<std::pair<int&, float&>> myvec{{i1, f1}, {i2, f2}}; std::map<int, float> m(boost::begin(myvec), boost::end(myvec)); // WORKS boost::bimap<int, float> b(boost::begin(myvec), boost::end(myvec)); // FAILS } The compiler errors are shown below. It seems to me this should work. As with std::map, the pair-of-iterators constructor should call something like insert(const value_type&) for each element of the range, where value_type is something like pair<const T, U> which should be constructible from pair<T&, U&>, the element type of the range. Why is this not working? Thanks, Nate. P.S. Here are the errors: In file included from B:\Dev\Libraries\boost/boost/bimap/detail/bimap_core.hpp:34:0, from B:\Dev\Libraries\boost/boost/bimap/bimap.hpp:61, from B:\Dev\Libraries\boost/boost/bimap.hpp:13, from test.cpp:1: B:\Dev\Libraries\boost/boost/multi_index_container.hpp: In constructor 'boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::multi_index_container(InputIterator, InputIterator, boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::ctor_args_list&, boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::allocator_type&) [with InputIterator = __gnu_cxx::__normal_iterator<std::pair<int&, float&>*, std::vector<std::pair<int&, float&> > >, Value = boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, IndexSpecifierList = boost::bimaps::detail::bimap_core<int, float, mpl_::na, mpl_::na, mpl_::na>::core_indices, Allocator = std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> >, boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::ctor_args_list = boost::tuples::cons<boost::tuples::tuple<boost::multi_index::member<boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, true>, float, &boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, true>::right>, std::less<float>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, boost::tuples::cons<boost::tuples::tuple<boost::multi_index::member<boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, true>, int, &boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, true>::left>, std::less<int>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, boost::tuples::null_type> >, boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::allocator_type = std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> >]': B:\Dev\Libraries\boost/boost/bimap/bimap.hpp:252:8: instantiated from 'boost::bimaps::bimap<KeyTypeA, KeyTypeB, AP1, AP2, AP3>::bimap(InputIterator, InputIterator, boost::bimaps::bimap<KeyTypeA, KeyTypeB, AP1, AP2, AP3>::allocator_type&) [with InputIterator = __gnu_cxx::__normal_iterator<std::pair<int&, float&>*, std::vector<std::pair<int&, float&> > >, KeyTypeA = int, KeyTypeB = float, AP1 = mpl_::na, AP2 = mpl_::na, AP3 = mpl_::na, boost::bimaps::bimap<KeyTypeA, KeyTypeB, AP1, AP2, AP3>::allocator_type = std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> >]' test.cpp:15:70: instantiated from here B:\Dev\Libraries\boost/boost/multi_index_container.hpp:235:9: error: no matching function for call to 'boost::multi_index::multi_index_container<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, boost::bimaps::detail::bimap_core<int, float, mpl_::na, mpl_::na, mpl_::na>::core_indices, std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> > >::insert_(std::pair<int&, float&>&, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> > > > >*)' B:\Dev\Libraries\boost/boost/multi_index_container.hpp:484:30: note: candidates are: std::pair<typename boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList, Allocator>::type::node_type*, bool> boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::insert_(const Value&) [with Value = boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, IndexSpecifierList = boost::bimaps::detail::bimap_core<int, float, mpl_::na, mpl_::na, mpl_::na>::core_indices, Allocator = std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> >, typename boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList, Allocator>::type::node_type = boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> > > > >] B:\Dev\Libraries\boost/boost/multi_index_container.hpp:505:30: note: std::pair<typename boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList, Allocator>::type::node_type*, bool> boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::insert_(const Value&, boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::node_type*) [with Value = boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, IndexSpecifierList = boost::bimaps::detail::bimap_core<int, float, mpl_::na, mpl_::na, mpl_::na>::core_indices, Allocator = std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> >, typename boost::multi_index::detail::multi_index_base_type<Value, IndexSpecifierList, Allocator>::type::node_type = boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> > > > >, boost::multi_index::multi_index_container<Value, IndexSpecifierList, Allocator>::node_type = boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true>, std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const int, boost::bimaps::relation::member_at::left>, boost::bimaps::tags::tagged<const float, boost::bimaps::relation::member_at::right>, mpl_::na, true> > > > >] mingw32-make: *** [test.exe] Error 1
participants (1)
-
Nathan Ridge