1- // Copyright (c) 2025 Pratyksh Gupta
1+ // Copyright (c) 2026 Pratyksh Gupta
22//
33// SPDX-License-Identifier: BSL-1.0
44// Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -19,11 +19,14 @@ static_assert(is_replaceable_v<int>);
1919// Const types are not assignable (thus not replaceable)
2020static_assert (!is_replaceable_v<int const >);
2121
22- // Pointer types are replaceable
22+ // Pointer types are replaceable if they are not const-qualified themselves.
2323static_assert (is_replaceable_v<int *>);
24- static_assert (is_replaceable_v<int const *>); // pointer itself is mutable
25- static_assert (
26- !is_replaceable_v<int * const >); // const pointer is not replaceable
24+ static_assert (is_replaceable_v<int const *>);
25+
26+ // Pointers follow the same rules as other objects. A pointer is replaceable only
27+ // if it is not const-qualified itself, as replacement requires assignment.
28+ // P2786R13 Section 3.2: "const-qualified objects are never replaceable."
29+ static_assert (!is_replaceable_v<int * const >);
2730
2831// Function pointers are replaceable
2932static_assert (is_replaceable_v<int (*)()>);
@@ -48,6 +51,10 @@ struct trivial_class
4851};
4952static_assert (is_replaceable_v<trivial_class>);
5053
54+ // Replaceability implies a type can be destroyed and reconstructed.
55+ // Consequently, a type must be destructible to be replaceable.
56+ // Per P2786R13, implicit replaceability also requires trivial relocatability,
57+ // which in turn requires trivial destructibility.
5158struct not_destructible
5259{
5360 not_destructible (not_destructible&&);
0 commit comments