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'
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With