|
Boost : |
From: Václav Veselý (vaclav.vesely_at_[hidden])
Date: 2006-03-29 01:05:13
David Abrahams wrote:
> I've developed some facilities that perhaps ought to be
> developed into full-fledged libraries or components of
> existing Boost libraries.
> This work centers around my long-standing threat to build a
> library that could create smart pointers safely, without ever
> exposing a raw pointer to the user. For example,
>
> #include <memory>
> #include <boost/shared_ptr.hpp>
> #include "new.hpp"
>
> struct foo
> {
> foo(int&, char const*, std::auto_ptr<int> const&);
> };
>
> std::auto_ptr<int> x(new_<int>(3));
> std::auto_ptr<foo> y(new_<foo>(*x, "hello, world", x));
> boost::shared_ptr<foo> z(new_<foo>(*x, (char const*)"hello,
> world", x));
>
> To solve this problem correctly, it was necessary to address
> "the forwarding problem"
> (http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm
> ). To that end, I developed some preprocessor macros that
> one can use to generate the necessary overload sets. Is
> there interest in adopting any of this code (enclosed), and
> if so, where should it go?
Yes, I'm interested.
IMHO maximum arity of about 5 isn't too restrictive. Except of this I would
like to have an alternative new_ with greater arity which use only const
reference forwarding. Non-const referrence parameters can be explicitly
wrapped with boost::ref.
I'm confused with syntax. new_<T> always creates auto_ptr<T>. How can I
create for example shared_ptr<T>?
How this is related to auto_overhead?
Regards,
Vaclav
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk