godzilla
godzilla

Reputation: 3125

can boost have maps with integer keys?

I have boost map with the definition as below:

typedef std::pair< int,complex_data > map_value_type;
typedef boost::interprocess::allocator<map_value_typemanaged_shared_memory::segment_manager> map_value_type_allocator;
typedef boost::interprocess::map<  int, complex_data, std::less<  int>,map_value_type_allocator > complex_map_type;

I took the code from http://www.boost.org/doc/libs/1_49_0/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained.containers_of_containers and replaced the keys with integers. However I am getting the following error i can not resolve:

/usr/include/boost/container/map.hpp:147:1: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’

If I replace the keys the code seems to work fine. Can anyone see what the problem is here?

Upvotes: 0

Views: 227

Answers (1)

MSalters
MSalters

Reputation: 180235

The error message is familiar to those with experience in C++ template programming. Ignore the sizeof part; the clue is in boost::STATIC_ASSERTION_FAILURE<false>. That type shouldn't be instantiated, you want boost::STATIC_ASSERTION_FAILURE<true>. But what exact expression is used as the template argument?

Your template instantiation error should have an instantiation stack, which leads from your code to the failure. Presumably it's checking

Upvotes: 1

Related Questions