This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Sat, 6 Nov 2010 16:48:08 +0000
- Subject: Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- References: <4CD49DCD.5070709@oracle.com>
We still have a regression in this program:
void del(int*);
std::unique_ptr<int, void(*)(int*)> p(new int, del);
I was going to fix it when adding constexpr, which is now done, but I
won't be able to do it before Monday.
I'm not sure what's the best way to allow that, but make the following
ill-formed as required:
std::unique_ptr<int, void(*)(int*)> p(new int);
I was thinking about using a non-default-constructible class to hold
the deleter when it's a pointer type and making unique_ptr::_M_t have
type
tuple<_Tp,
typename conditional<is_pointer<_Dp>::value,
not_null<_Dp>, _Dp>::type>
so that the unique_ptr constructors which value-initialize the deleter
will be ill-formed. That should work for the constexpr constructors,
unlike a static_assert in the ctor body.
Better suggestions are welcome.