Date: Sun, 10 Nov 2024 15:43:14 +0100
On 11/10/24 11:04, André Offringa via Std-Proposals wrote:
> I'd like to float the idea to make it possible to construct a
> std::complex and a std::vector uninitialized. Basically, I would propose
> something like the following to exist.
Another approach is to use a wrapper that leaves the enclosed value
uninitialized by default. You probably want to constrain such a wrapper
to only work for trivially destructible types.
With such a wrapper you can use:
std::vector<uninitialized<char>> a;
std::complex<uninitialized<double>> b;
This will work with other existing containers as well.
There was a proposal to add std::uninitialized, but that proposal has
morphed into something else:
https:://wg21.link/P3074
> I'd like to float the idea to make it possible to construct a
> std::complex and a std::vector uninitialized. Basically, I would propose
> something like the following to exist.
Another approach is to use a wrapper that leaves the enclosed value
uninitialized by default. You probably want to constrain such a wrapper
to only work for trivially destructible types.
With such a wrapper you can use:
std::vector<uninitialized<char>> a;
std::complex<uninitialized<double>> b;
This will work with other existing containers as well.
There was a proposal to add std::uninitialized, but that proposal has
morphed into something else:
https:://wg21.link/P3074
Received on 2024-11-10 14:43:20