From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-07-28 10:29:27
On Mon, 2008-07-28 at 08:52 -0400, Frank Mori Hess wrote:
> I don't think the zero-argument call to make_shared resolves to the variadic
> template, see the make_shared.hpp file.
I've seen that, but:
a) I don't understand what the "new T()" vs. "new T" issue is - and
there seems to be nothing in the code which explains that. It does use
new T(), which should also work for new T( Args... ) if Args is a
zero-sized parameter pack, shouldn't it?
b) Looking at N2352 and N2691, there should be only one make_shared.
Boost vs. GCC already shows that looking at a concrete implementation is
not enough. Question is, what is/should be guaranteed by the standard.
If nothing like this is guaranteed (probably because it's simply too
late?), I would end up with non-portable code. Even then I would be
interested in whether or not you, Peter, etc. think if something like
that should be at least targeted for TR2...
c) I just realized that the friend declaration is not yet correct. I
think the correct (and generic) version should read:
// private ctors...
A( int, double );
// allow creation through make_shared
template<typename T, typename... Args>
friend std::shared_ptr<T> std::make_shared( Args&&... );
One might also need to add a friend declaration for allocate_shared if
you intend to allow that, too.
d) Besides the use case above, what do you think about using this
pattern to allow shared_from_this to be called in the ctor? Is this
possible? Would it be useful?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk