Skip to content

Support facades that forbid destruction - #111

Merged
mingxwa merged 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/destroy
Nov 22, 2026
Merged

mingxwa merged 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/destroy

Conversation

@mingxwa

@mingxwa mingxwa commented Nov 18, 2026 •

Copy link
Copy Markdown
Member
  • 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.

- 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
mingxwa force-pushed the user/mingxwa/destroy branch from 4e87490 to 8ff5798 Compare November 21, 2026 06:14
@mingxwa mingxwa changed the title Delete the destructor of proxy for facades that forbid destruction Support facades that forbid destruction Nov 21, 2026
@mingxwa
mingxwa marked this pull request as ready for review November 21, 2026 06:21
@mingxwa
mingxwa merged commit 291f46e into ngcpp:feature/v5 Nov 22, 2026
20 checks passed
@mingxwa
mingxwa deleted the user/mingxwa/destroy branch November 22, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant