Modify

Ticket #6533 (closed Bugs: fixed)

Opened 2 years ago

Last modified 20 months ago

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

Change History

comment:1 Changed 2 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 20 months ago by igaztanaga

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

Fixed in Boost 1.50

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
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.