C++ Logo


Advanced search

Re: [std-proposals] std::atomic<bool> trivial constructor/destructor dropped in C++17 spec wording

From: Jeremy Hurwitz <hurwitz_at_[hidden]>
Date: Mon, 19 Jun 2023 22:10:09 -0700
> > Is this a defect in the current spec? Thanks!
> Since C++17, std::atomic value-initializes its contained value, see:
> http://eel.is/c++draft/atomics#types.operations-2
> Therefore it cannot be trivially-constructible. std::atomic<bool> is not
> special in this regard.

Good catch. Verified via godbolt that
`std::is_trivially_constructible_v<std::atomic<bool>>` is true in C++17 and
false in C++20. So that defect only applies to C++17 and before.

Looks like the trivially-destructible part still applies in C++20.

Received on 2023-06-20 05:10:24