Boost logo

Boost :

Subject: Re: [boost] Is there any interest in a smart pointer facade class?
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-09-22 14:04:58


Zitat von David Abrahams <dave_at_[hidden]>:

> On Sep 22, 2010, at 12:35 PM, Cory Nelson wrote:
>>
>>> Recently I wrote two smart pointer classes, and felt the need for such a
>>> class. I would like to write such a class, and if everything goes well,
>>> perhaps add it to the Boost library.
>>
>> It is supposed to be something like a more powerful intrusive_ptr?
>> Can you give a usage example?
>
> I think the general idea is that this would be closer to a
> policy-based smart pointer.
>

I think it`s neither, but a CRTP class implementing the "pointer concept":

struct my_ptr
   : smart_ptr_facade<my_ptr,...>{
   void set(T *rhs){ ptr=rhs; }
   T *get() const{ return ptr; }
   T *ptr;
};

=> my_ptr has ptr semantics, including operator->, operator=, ...

iterator_facade simplifies implementing iterators a lot, so could this
class for pointers, and other facades, e.g. a vector_facade that
implements the std::vector interface in terms of 3 or 4 user-supplied
functions.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk