tags:

views:

66

answers:

1

If I want to create a unique_ptr of type QueueList (some self defined object), how do I define a deletor for it or is there already a template 'Deletor' I can use?

I want a unique_ptr so I can safely transfer the object between threads, without sharing it between the 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' : use of class template requires template argument list : see declaration of 'boost::interprocess::unique_ptr'

+2  A: 

Here is a simple deleter class that just calls delete on any given object:

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

You can then use it with unique_ptr like this:

boost::interprocess::unique_ptr<QueueList, Deleter<QueueList> > LIST;
Amanieu