これは私がこれまで行ってきたことです。しかし、これはコンパイルさえしません。私はそれを動作させるために何をすべきですか?ブーストマップ内のブーストマップを共有メモリに挿入する
typedef allocator<int, managed_shared_memory::segment_manager> vecAllocator;
typedef vector<int, vecAllocator> vec;
typedef std::pair<const int, vec> ValueType;
typedef allocator<ValueType, managed_shared_memory::segment_manager> ShmemAllocator;
typedef multimap<int, vec, std::less<int>, ShmemAllocator> MyMap;
ShmemAllocator alloc_inst (segment.get_segment_manager());
vecAllocator vectorallocator (segment.get_segment_manager());
MyMap *mymap = segment.construct<MyMap>("MyMap")(std::less<int>(),alloc_inst);
vec *myvec = segment.construct<vec>("myvec")(std::less<int>(), vectorallocator);
myvec->push_back(10);
このベクターをマップに挿入するにはどうすればよいですか? これは私が
mymap->insert(std::pair<const int, vec>(i, myvec));
を試みたが、動作しているように見えるdoes notのものの一つです。私は共有メモリ内のベクトルへのポインタを作成することは正しい方法ではないことを知っています。私はマップに挿入する場合は、オブジェクトを作成する必要があります。共有メモリーにこれらのものを組み込む方法や、それをどうやって行うのですか?
グラム++によってスローエラーがある:
sharedMap.cpp:46: no matching function for call to ‘std::pair<const int, boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > > >::pair(int&, main()::vec*&)’
/usr/include/c++/4.2.1/bits/stl_pair.h:84: note: candidates are: std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = const int, _T2 = boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > >]
/usr/include/c++/4.2.1/bits/stl_pair.h:80: note: std::pair<_T1, _T2>::pair() [with _T1 = const int, _T2 = boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > >]
/usr/include/c++/4.2.1/bits/stl_pair.h:69: note: std::pair<const int, boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > > >::pair(const std::pair<const int, boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > > >&)
/usr/local/include/boost/preprocessor/iteration/detail/local.hpp: In member function ‘void boost::interprocess::detail::Ctor2Arg<T, is_iterator, P0, P1>::construct(void*, boost::interprocess::detail::false_) [with T = boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > >, bool is_iterator = false, P0 = std::less<int>, P1 = boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >]’:
/usr/local/include/boost/preprocessor/iteration/detail/local.hpp:40: instantiated from ‘void boost::interprocess::detail::Ctor2Arg<T, is_iterator, P0, P1>::construct_n(void*, size_t, size_t&) [with T = boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > >, bool is_iterator = false, P0 = std::less<int>, P1 = boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >]’
sharedMap.cpp:54: instantiated from here
/usr/local/include/boost/preprocessor/iteration/detail/local.hpp:40: error: no matching function for call to ‘boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> > >::vector(const std::less<int>&, const boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >&)’
/usr/local/include/boost/interprocess/containers/container/vector.hpp:474: note: candidates are: boost::container::vector<T, A>::vector(boost::interprocess::rv<boost::container::vector<T, A> >&) [with T = int, A = boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >]
/usr/local/include/boost/interprocess/containers/container/vector.hpp:465: note: boost::container::vector<T, A>::vector(const boost::container::vector<T, A>&) [with T = int, A = boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >]
/usr/local/include/boost/interprocess/containers/container/vector.hpp:456: note: boost::container::vector<T, A>::vector(typename A::size_type, const T&, const A&) [with T = int, A = boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >]
/usr/local/include/boost/interprocess/containers/container/vector.hpp:445: note: boost::container::vector<T, A>::vector(typename A::size_type) [with T = int, A = boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >]
/usr/local/include/boost/interprocess/containers/container/vector.hpp:434: note: boost::container::vector<T, A>::vector(const A&) [with T = int, A = boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0ul>, boost::interprocess::iset_index> >]
ライン54は
線46はmymap->インサートラインである(戻り)主に戻り、最後の行です。
"が、doesntのは動作するようです" - 何が起こりますか? – sehe
私はペアを 'std :: pair(i、* myvec)'として作成するべきだと思います。 –
yasouser
それはエラーの最初の5行をeleminates ..残りはまだ残って.. –