Opened 6 years ago

#12789 new Bugs

Instantiating bimap with all three "additional" template parameter fails to compile.

Reported by: jonathan.haigh@… Owned by: Matias Capeletto
Milestone: To Be Determined Component: bimap
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

The following test program fails to compile.

#include <boost/bimap.hpp>
#include <memory>

void test() {
  boost::bimap<int, int, boost::bimaps::left_based, boost::bimaps::with_info<int>, std::allocator<void>> map;
}

The compile error from g++ 4.9.2 starts with:

jhaigh@growler:~/tmp/tmp$ g++ -std=c++11 bimap_error.cpp
In file included from /usr/include/boost/bimap/bimap.hpp:61:0,
                 from /usr/include/boost/bimap.hpp:13,
                 from bimap_error.cpp:1:
/usr/include/boost/bimap/detail/bimap_core.hpp: In instantiation of ‘class boost::bimaps::detail::bimap_core<int, int, boost::bimaps::left_based, boost::bimaps::with_info<int>, std::allocator<void> >’:
/usr/include/boost/bimap/bimap.hpp:133:7:   required from ‘class boost::bimaps::bimap<int, int, boost::bimaps::left_based, boost::bimaps::with_info<int>, std::allocator<void> >’
bimap_error.cpp:5:106:   required from here
/usr/include/boost/bimap/detail/bimap_core.hpp:410:7: error: no class template named ‘rebind’ in ‘boost::bimaps::detail::manage_additional_parameters<boost::bimaps::left_based, boost::bimaps::with_info<int>, std::allocator<void> >::case_SHA::allocator {aka struct boost::bimaps::with_info<int>}’
...

Boost thinks my with_info parameter is an allocator! The full compiler output will be attached, but I think this is enough to see the problem.

It looks like the cause is the case_SHA struct in boost/bimap/detail/manage_additional_parameters that deals with the case when all three additional template parameters are given to bimap:

template< class AP1, class AP2, class AP3 >
struct manage_additional_parameters
{
...
    struct case_SHA
    {
        typedef AP1 set_type_of_relation;
        typedef AP2 allocator;
        typedef BOOST_DEDUCED_TYPENAME AP2::value_type additional_info;
    };

AP2 is used for both the allocator type and the additional_info type. I think allocator should be typedefed to AP3, not AP2.

Attachments (1)

bimap_compile_error.txt (11.6 KB ) - added by Jonathan Haigh <jonathan.haigh@…> 6 years ago.

Download all attachments as: .zip

Change History (1)

by Jonathan Haigh <jonathan.haigh@…>, 6 years ago

Attachment: bimap_compile_error.txt added
Note: See TracTickets for help on using tickets.