Hello,
I am trying to initialize a bimap with a vector>
(the "vector" part isn't important, any range with elements
of type pair has the same effect), but I'm getting a rather
monstrous compiler error.
The same initialization works for std::map.
Here is the code:
#include
#include
#include
#include <vector>
#include <map>
#include <utility>
int main()
{
int i1, i2;
float f1, f2;
std::vector> myvec{{i1, f1}, {i2, f2}};
std::map m(boost::begin(myvec), boost::end(myvec)); // WORKS
boost::bimap 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
which should be constructible from pair, 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::multi_index_container(InputIterator, InputIterator, boost::multi_index::multi_index_container::ctor_args_list&, boost::multi_index::multi_index_container::allocator_type&) [with InputIterator = __gnu_cxx::__normal_iterator*, std::vector > >, Value = boost::bimaps::relation::mutant_relation, boost::bimaps::tags::tagged, mpl_::na, true>, IndexSpecifierList = boost::bimaps::detail::bimap_core::core_indices, Allocator = std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> >, boost::multi_index::multi_index_container::ctor_args_list = boost::tuples::cons, boost::bimaps::tags::tagged, true>, float, &boost::bimaps::relation::detail::relation_storage, boost::bimaps::tags::tagged, 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::bimaps::tags::tagged, true>, int, &boost::bimaps::relation::detail::relation_storage, boost::bimaps::tags::tagged, 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::allocator_type = std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> >]':
B:\Dev\Libraries\boost/boost/bimap/bimap.hpp:252:8: instantiated from 'boost::bimaps::bimap::bimap(InputIterator, InputIterator, boost::bimaps::bimap::allocator_type&) [with InputIterator = __gnu_cxx::__normal_iterator*, std::vector > >, KeyTypeA = int, KeyTypeB = float, AP1 = mpl_::na, AP2 = mpl_::na, AP3 = mpl_::na, boost::bimaps::bimap::allocator_type = std::allocator, boost::bimaps::tags::tagged, 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::tags::tagged, mpl_::na, true>, boost::bimaps::detail::bimap_core::core_indices, std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> > >::insert_(std::pair&, boost::multi_index::detail::ordered_index_node, boost::bimaps::tags::tagged, mpl_::na, true>, std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> > > > >*)'
B:\Dev\Libraries\boost/boost/multi_index_container.hpp:484:30: note: candidates are: std::pair::type::node_type*, bool> boost::multi_index::multi_index_container::insert_(const Value&) [with Value = boost::bimaps::relation::mutant_relation, boost::bimaps::tags::tagged, mpl_::na, true>, IndexSpecifierList = boost::bimaps::detail::bimap_core::core_indices, Allocator = std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> >, typename boost::multi_index::detail::multi_index_base_type::type::node_type = boost::multi_index::detail::ordered_index_node, boost::bimaps::tags::tagged, mpl_::na, true>, std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> > > > >]
B:\Dev\Libraries\boost/boost/multi_index_container.hpp:505:30: note: std::pair::type::node_type*, bool> boost::multi_index::multi_index_container::insert_(const Value&, boost::multi_index::multi_index_container::node_type*) [with Value = boost::bimaps::relation::mutant_relation, boost::bimaps::tags::tagged, mpl_::na, true>, IndexSpecifierList = boost::bimaps::detail::bimap_core::core_indices, Allocator = std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> >, typename boost::multi_index::detail::multi_index_base_type::type::node_type = boost::multi_index::detail::ordered_index_node, boost::bimaps::tags::tagged, mpl_::na, true>, std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> > > > >, boost::multi_index::multi_index_container::node_type = boost::multi_index::detail::ordered_index_node, boost::bimaps::tags::tagged, mpl_::na, true>, std::allocator, boost::bimaps::tags::tagged, mpl_::na, true> > > > >]
mingw32-make: *** [test.exe] Error 1