Repository navigation
Support facades that forbid destruction - #111
Merged
Merged
Conversation
mingxwa
requested review from
guominrui,
tian-lt,
tian-lt-personal and
zhihaoy
November 18, 2026 14:43
mingxwa
force-pushed
the
user/mingxwa/destroy
branch
from
November 18, 2026 15:07
b9c93a4 to
898f5b1
Compare
mingxwa
marked this pull request as draft
November 18, 2026 21:19
mingxwa
force-pushed
the
user/mingxwa/destroy
branch
2 times, most recently
from
November 19, 2026 14:36
b881717 to
4e87490
Compare
- Added a deleted destructor for `F::destructibility == lifetime_requirement::none`, because `proxy` was ill-formed for such a facade when no destructor could be selected. It is declared before the other destructors, because NVHPC 26.3 otherwise selected it while checking `*this = proxy{rhs}` in a member template and rejected code that never used such a facade.
- Stopped delegating in `proxy(std::nullptr_t)`, because GCC, Clang and MSVC reject a delegating constructor of a class whose destructor is deleted. The destructor would run if the delegating constructor exited via an exception ([except.ctor]/4).
- Excluded the relocating `swap` when destruction is forbidden, because it needs a temporary `proxy`.
- Changed the constraints of the pointer and in-place constructors from `std::is_constructible_v` to the placement *new-expression* in the constraints of `std::construct_at`, and their `noexcept` specifications from `std::is_nothrow_constructible_v` to whether that expression is non-throwing, because the traits also require a destructor, so a pointer that is not destructible could not be stored when `F::destructibility == lifetime_requirement::none`.
- Changed the `supported` and `nothrow` copyability requirements on the contained type, and the `noexcept` specification of the internal copy, to the same expression with `const P&`, because `std::is_copy_constructible_v` and `std::is_nothrow_copy_constructible_v` also require a destructor, so a copyable facade could not store a pointer that is not destructible, and a pointer whose destructor may throw could not meet `nothrow`.
- Defined the exposition-only concepts *constructible* and *nothrow-constructible* in the *ProxyFacade* requirements, with the reason they differ from the standard traits, and used them in the new copyability mapping there and in the constructor synopsis, so that neither spells out the *new-expression*.
- Kept `emplace` and the pointer assignment on the traits, because they require a destructible facade, so the contained type is destructible there.
- Added static assertions for the deleted destructor, the `swap` constraint, and the constraint and the `noexcept` specification of each constructor, requirement checks for the `supported` and `nothrow` copyability of a pointer that is not destructible or whose destructor may throw, a test that constructs such a `proxy` with a *new-expression*, and a test that stores and copies a non-destructible pointer.
mingxwa
force-pushed
the
user/mingxwa/destroy
branch
from
November 21, 2026 06:14
4e87490 to
8ff5798
Compare
mingxwa
marked this pull request as ready for review
November 21, 2026 06:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
F::destructibility == lifetime_requirement::none, becauseproxywas ill-formed for such a facade when no destructor could be selected. It is declared before the other destructors, because NVHPC 26.3 otherwise selected it while checking*this = proxy{rhs}in a member template and rejected code that never used such a facade.proxy(std::nullptr_t), because GCC, Clang and MSVC reject a delegating constructor of a class whose destructor is deleted. The destructor would run if the delegating constructor exited via an exception ([except.ctor]/4).swapwhen destruction is forbidden, because it needs a temporaryproxy.std::is_constructible_vto the placement new-expression in the constraints ofstd::construct_at, and theirnoexceptspecifications fromstd::is_nothrow_constructible_vto whether that expression is non-throwing, because the traits also require a destructor, so a pointer that is not destructible could not be stored whenF::destructibility == lifetime_requirement::none.supportedandnothrowcopyability requirements on the contained type, and thenoexceptspecification of the internal copy, to the same expression withconst P&, becausestd::is_copy_constructible_vandstd::is_nothrow_copy_constructible_valso require a destructor, so a copyable facade could not store a pointer that is not destructible, and a pointer whose destructor may throw could not meetnothrow.emplaceand the pointer assignment on the traits, because they require a destructible facade, so the contained type is destructible there.swapconstraint, and the constraint and thenoexceptspecification of each constructor, requirement checks for thesupportedandnothrowcopyability of a pointer that is not destructible or whose destructor may throw, a test that constructs such aproxywith a new-expression, and a test that stores and copies a non-destructible pointer.