Boost logo

Boost Users :

Subject: [Boost-users] [Container][Interprocess] Can't use map with incomplete type and interprocess allocator
From: Jensen, Erik A (Erik.Jensen_at_[hidden])
Date: 2012-02-07 14:12:34

The following code gives me a compiler error on Visual Studio 2010 with both Boost 1.48 and 1.49beta1:

#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>, Allocator1> IncompleteMap;
class Incomplete
    IncompleteMap blah;

This code compiles fine if I instead use std::allocator.

As best as I can tell from the compiler message, at some point in the instantiation of map, boost::container::container_detail::version<T> is instantiated with

Which results in boost::container::container_detail::is_convertable<T,U> being instantiated with
    boost::interprocess::allocator<...>, // Same as above

Somehow (I'm quite fuzzy on this), this results in boost::container::container_detail::rbtree_node<T,VoidPointer> being instantiated with T=std::pair<std::string,Incomplete>. This then results in the pair being instantiated, which has a member of type Incomplete... BOOM!

If I replace container_detail::is_convertible in extract_version with boost::is_convertible from Boost.TypeTraits (or with std::is_convertible, for that matter), the code above successfully compiles. Is this a valid temporary workaround, or will it lead to other complications?

Thank you,
Erik Jensen

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at