我想在共享内存中创建一个unordered_map.我正在使用allocator来达到目的.
代码
void *addr;
void *pool;
int shmid;
template<class T>
class MyPoolAlloc {
private:
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
template<class X>
struct rebind
{ typedef MyPoolAlloc<X> other; };
MyPoolAlloc() throw() {
}
MyPoolAlloc(const MyPoolAlloc&) throw() {
}
template<class X>
MyPoolAlloc(const MyPoolAlloc<X>&) throw() {
}
~MyPoolAlloc() throw() {
}
pointer address(reference __x) const { return &__x; }
const_pointer address(const_reference __x) const { …Run Code Online (Sandbox Code Playgroud)