STL icon indicating copy to clipboard operation
STL copied to clipboard

P3309R3 `constexpr` `atomic` And `atomic_ref`

Open StephanTLavavej opened this issue 1 year ago • 3 comments

WG21-P3309R3 constexpr atomic And atomic_ref

Feature-test macro (expected):

#define __cpp_lib_constexpr_atomic 202411L

Note: We're focused on implementing the remaining library-only features in C++23. Until that's done, we will NOT be accepting PRs for C++26 features.

StephanTLavavej avatar Nov 25 '24 23:11 StephanTLavavej

It seems that compiler support is required to bypass non-trivial copy/move function templates that hijacks normal copy/move functions...

frederick-vs-ja avatar Mar 17 '25 10:03 frederick-vs-ja

Can you explain a scenario where that's implied by the Standardese? My cat-sized brain isn't following.

StephanTLavavej avatar Mar 17 '25 22:03 StephanTLavavej

Can you explain a scenario where that's implied by the Standardese? My cat-sized brain isn't following.

#include <atomic>

struct S {
    S() = default;
    S(S&&) = default;
    S& operator=(const S&) = default;
    S& operator=(S&&) = default;

    S(const volatile S&) = delete;
    template<class = void>
    S(const S&) {}
};

int main() {
    std::atomic<S> a [[maybe_unused]] = S{};
}

Hmm, it seems to me that the constructor template in this example should be ignored (but libstdc++ and MSVC STL use it; Godbolt link).

For store etc., an assignment operator template might matter.

frederick-vs-ja avatar Mar 17 '25 23:03 frederick-vs-ja