Boost unique_ptr deletor

If I want to create a unique_ptrtype QueueList(some self-defined object), how do I define a handle for it or is there already a "Deletor" template that I can use?

I want unique_ptrme to be able to safely transfer an object between threads without sharing it between threads.

EDIT

boost::interprocess::unique_ptr<QueueList> LIST;  ///FAILS to COMPILE!!!

LIST mylist;

Compiler: MS Visual Studio 2003

ERROR:

error C2976: "boost :: interprocess :: unique_ptr": too few template arguments

error C2955: 'boost :: interprocess :: unique_ptr': using a class template requires a list of template arguments: see the declaration "boost :: interprocess :: unique_ptr"

+5
source share
1 answer

deleter, delete :

template<typename T> struct Deleter {
    void operator()(T *p)
    {
        delete p;
    }
};

unique_ptr :

boost::interprocess::unique_ptr<QueueList, Deleter<QueueList> > LIST;
+9

All Articles