Modify

Opened 5 years ago

Closed 5 years ago

#6533 closed Bugs (fixed)

Can't use map with incomplete type and interprocess allocator

Reported by: Erik Jensen <Erik.Jensen@…> Owned by: igaztanaga
Milestone: To Be Determined Component: container
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

A boost::container::map using boost::interprocess::allocator cannot be instantiated with an incomplete value type, even though the allocator itself can be.

Sample code:

#include <string>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>

class Incomplete;
typedef boost::interprocess::allocator<std::pair<std::string, Incomplete>,
    boost::interprocess::managed_shared_memory::segment_manager> Allocator;
typedef boost::interprocess::map<std::string, Incomplete,
    std::less<std::string>, Allocator> IncompleteMap;
class Incomplete
{
    Allocator foo;      // No error here
    IncompleteMap bar;  // Error!
};

The error occurs as part of the instantiation of boost::container::container_detail::is_convertible by boost::container::container_detail::impl::extract_version. Using using boost::is_convertible instead fixes the problem on Visual Studio 20103

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by igaztanaga

First of all, the code is wrong as the first parameter of std::pair should be const:

boost::interprocess::allocator<std::pair<CONST std::string, Incomplete>,

Does this compile? My local version (for boost 1.50) compiles, so it will be fixed.

#include <string> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/containers/map.hpp> #include <boost/interprocess/managed_shared_memory.hpp>

class Incomplete; typedef boost::interprocess::allocator<std::pair<const std::string, Incomplete>,

boost::interprocess::managed_shared_memory::segment_manager> Allocator;

typedef boost::interprocess::map<std::string, Incomplete,

std::less<std::string>, Allocator> IncompleteMap?;

class Incomplete {

Allocator foo; No error here IncompleteMap? bar; Error! public: Incomplete()

: foo(0), bar(IncompleteMap::key_compare(), foo)

{}

};

int main() {

Incomplete incomplete; return 0;

}

comment:2 Changed 5 years ago by igaztanaga

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in Boost 1.50

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain igaztanaga.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.