Hi all,
I'm having issues compiling boost::unordered_map with boost::interprocess. I'm using boost 1.57 and compiler is GCC 4.1.2 . I've tried to ask it on SO few months ago, but got no solution for it and decided to use just map. Now I'm seeking for some performance improvement again, so I will try my luck here.
I took code from the answer on SO (http://stackoverflow.com/questions/29557680/boost-interprocess-unordered-map...) with minimal changes to make it work under non C++11 compiler. It looks better than my and there are same errors generated.
Code:
#include
#include
#include
#include
namespace bip = boost::interprocess;
// ShmString is boost::interprocess::basic_string
typedef bip::allocator CharAllocator;
typedef bip::basic_string ShmString;
typedef ShmString HashKeyType;
// ComplexType is a wrapper for internal interprocess::map
struct ComplexType {
typedef bip::allocator, bip::managed_shared_memory::segment_manager> Alloc;
typedef bip::map Map;
template <typename Alloc2>
ComplexType(std::string, Alloc2 const& alloc) : map(alloc) {}
Map map;
};
typedef ComplexType HashMappedType;
typedef std::pair HashValueType;
typedef bip::allocator HashMemAllocator;
typedef boost::unordered_map
TestHashMap;
int main()
{
// Allocation:
{
bip::managed_shared_memory segment(bip::open_or_create, "MySharedMemory", 65536);
TestHashMap * thm_ = segment.construct<TestHashMap>("TestHashMap")(3, boost::hash<ShmString>(), std::equal_to<ShmString>(),
segment.get_allocator<HashValueType>());
}
// Usage:
bip::managed_shared_memory segment(bip::open_only, "MySharedMemory");
TestHashMap * thm_ = segment.construct<TestHashMap>("TestHashMap")(3, boost::hash<ShmString>(), std::equal_to<ShmString>(), segment.get_allocator<HashValueType>());
ShmString str("123.345", segment.get_allocator<ShmString>());
ComplexType th("MySharedMemory", segment.get_segment_manager());
HashValueType value(str, th);
thm_->insert(value);
}
And here is some error output:
../boost_1_57/include/boost/unordered/detail/allocate.hpp: In instantiation of 'boost::unordered::detail::allocator_traits, 0ul>, boost::interprocess::iset_index> > >, ComplexType> >, boost::interprocess::segment_manager, 0ul>, boost::interprocess::iset_index> > >::pointer_to_other, 0ul>, boost::interprocess::iset_index> > >, ComplexType> > >':
../boost_1_57/include/boost/unordered/detail/allocate.hpp:535: instantiated from 'boost::unordered::detail::allocator_traits, 0ul>, boost::interprocess::iset_index> > >, ComplexType> >, boost::interprocess::segment_manager, 0ul>, boost::interprocess::iset_index> > >'
../boost_1_57/include/boost/unordered/detail/unique.hpp:122: instantiated from 'boost::unordered::detail::pick_node, 0ul>, boost::interprocess::iset_index> > >, ComplexType>, boost::interprocess::segment_manager, 0ul>, boost::interprocess::iset_index> >, std::pair, 0ul>, boost::interprocess::iset_index> > >, ComplexType> >'
../boost_1_57/include/boost/unordered/detail/unique.hpp:166: instantiated from 'boost::unordered::detail::map, 0ul>, boost::interprocess::iset_index> > >, ComplexType>, boost::interprocess::segment_manager, 0ul>, boost::interprocess::iset_index> >, boost::container::basic_string, 0ul>, boost::interprocess::iset_index> > >, ComplexType, boost::hash, 0ul>, boost::interprocess::iset_index> > > >, std::equal_to, 0ul>, boost::interprocess::iset_index> > > > >'
../boost_1_57/include/boost/unordered/unordered_map.hpp:60: instantiated from 'boost::unordered::unordered_map, 0ul>, boost::interprocess::iset_index> > >, ComplexType, boost::hash, 0ul>, boost::interprocess::iset_index> > > >, std::equal_to, 0ul>, boost::interprocess::iset_index> > > >, boost::interprocess::allocator, 0ul>, boost::interprocess::iset_index> > >, ComplexType>, boost::interprocess::segment_manager, 0ul>, boost::interprocess::iset_index> > >'
src/Main.cpp:453: instantiated from here
../boost_1_57/include/boost/unordered/detail/allocate.hpp:531: error: ambiguous class template instantiation for 'struct boost::pointer_to_other, 0ul>, boost::interprocess::iset_index> > >, ComplexType> >, long int, long unsigned int, 0u>, const boost::unordered::detail::ptr_node, 0ul>, boost::interprocess::iset_index> > >, ComplexType> > >'
../boost_1_57/include/boost/interprocess/offset_ptr.hpp:742: error: candidates are: struct boost::pointer_to_other, U>
../boost_1_57/include/boost/pointer_to_other.hpp:29: error: struct boost::pointer_to_other
../boost_1_57/include/boost/pointer_to_other.hpp:36: error: struct boost::pointer_to_other, U>
../boost_1_57/include/boost/pointer_to_other.hpp:43: error: struct boost::pointer_to_other, U>
../boost_1_57/include/boost/unordered/detail/allocate.hpp:531: error: invalid use of undefined type 'struct boost::pointer_to_other, 0ul>, boost::interprocess::iset_index> > >, ComplexType> >, long int, long unsigned int, 0u>, const boost::unordered::detail::ptr_node, 0ul>, boost::interprocess::iset_index> > >, ComplexType> > >'
Is it possible to fix this problem without switching updating the compiler?
Thanks and regards.
===============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
===============================================================================