Boost logo

Boost Users :

From: Da Xu (djsignal7_at_[hidden])
Date: 2021-12-08 04:25:13


Hi folks,

got a couple of questions about using shared memory allocators. Please see below.

I have the following code
template <typename T> using CAP_Alloc = cached_adaptive_pool<T, segment_manager_t>; using CAP_Shmem_String = basic_string<char, std::char_traits<char>, CAP_Alloc<char> >;
using CAP_Shmem_String_Alloc = CAP_Alloc<CAP_Shmem_String>;
using CAP_Shmem_Void_Alloc = CAP_Alloc<void>;

class MyDataBlock{
    using pointer = CAP_Shmem_String_Alloc::pointer;
    pointer strData;    float extraData;
    MyDataBlock(): strData(nullptr), extraData(0.0) {}    MyDataBlock(const CAP_Shmem_Void_Alloc& alloc)    {        /*        My question is how do I convert CAP_Shmem_Void_Alloc to type CAP_Shmem_String_Alloc to call allocate? And do I pass in the void allocator as a construction argument? Is there a difference between allocate and construct?

        */
    }
    ~MyDataBlock()    {        /*        To delete the memory, do I need to keep around a copy of the original allocator, so I can call deallocate or destroy? Or can that be derived or converted from somewhere, like calling strData->alloc() ?
    
        */
    }

}
Any help would be greatly appreciated.
Thank you. 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net