|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-07-28 08:52:45
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 28 July 2008 04:12 am, Daniel Frey wrote:
> On Sun, 2008-07-27 at 18:25 +0300, Peter Dimov wrote:
> > You should be able to make it work by making the appropriate make_shared
> > overload a friend:
> >
> > template< class T, class A1, class A2 >
> > friend
> > boost::shared_ptr< T > boost::make_shared( A1 const & a1, A2 const & a2
> > );
>
> Good idea, thanks. It would also render create() useless, since the user
> could call make_shared directly. Sadly, it doesn't work for me. I've
> tried it with GCC 4.3:
>
> #include <memory>
>
> class A
> {
> private:
> A() {}
>
> public:
> static std::shared_ptr< A > create()
> { return std::make_shared< A >(); }
>
> template< typename... Args >
> friend std::shared_ptr< A > std::make_shared( Args... );
I don't think the zero-argument call to make_shared resolves to the variadic
template, see the make_shared.hpp file.
> };
>
> int main()
> {
> A::create();
> }
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIjcEj5vihyNWuA4URAmrmAJ0R7ZTjR0OmdWSJqKjhYkTrt/VylACeIYXu
4Ay4ntVFHkC0xnogG1L7Cfs=
=Zr3Z
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk