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
On 9 November 2010 17:25, Benjamin Kosnik wrote:
>
> The only use I see right now for a default-constructed constexpr
> unique_ptr is to have a non-dymamically-initialized check for a "null"
> unique_ptr. So I'm a bit curious about this design decision.
IIUC then a non-const, default-constructed, global unique_ptr should
be statically-initialized because it's ctor is constexpr.
This means I can put:
extern std::unique_ptr<EvilSingleton> global_evil;
in a header, define it in one TU, and avoid the static initialization
order fiasco. It will be (value) initialized before the program
starts.
- References:
- [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc
- Re: [v3] Add constexpr specifiers to std::shared_ptr, std::unique_ptr, etc