これは恥ずかしい質問ですが、boost.interprocessで提供されるよく書かれたドキュメントでさえ、これを行う方法を理解するのに十分ではありませんでした。
私が持っているのはcached_adaptive_poolアロケータインスタンスであり、これを使用してオブジェクトを構築し、コンストラクターパラメーターを渡します。
struct Test {
Test(float argument, bool flag);
Test();
};
// Normal construction
Test obj(10, true);
// Normal dynamic allocation
Test* obj2 = new Test(20, false);
typedef managed_unique_ptr<
Test, boost::interprocess::managed_shared_memory>::type unique_ptr;
// Dynamic allocation where allocator_instance == cached_adaptive_pool,
// using the default constructor
unique_ptr obj3 = allocator_instance.allocate_one()
// As above, but with the non-default constructor
unique_ptr obj4 = allocator_instance ... ???
これは、一般的なアロケータオブジェクトの使用方法に関する私の側の失敗である可能性が非常に高いです。しかし、いずれにせよ、cached_adaptive_poolで指定されたインターフェイスを使用して、この特定のアロケータを使用してコンストラクター引数をオブジェクトに渡す方法がわかりません。
cached_adaptive_pool
方法があります:void construct(const pointer & ptr, const_reference v)
しかし、それが何を意味するのか理解できず、それを使用した例を見つけることができません。
私の頭は一日中テンプレートで泳いでいるので、答えが明白であっても、助けの手は大いに感謝されます。