Skip to content

Construct the contained value of proxy without requiring a destructor - #115

Closed
mingxwa wants to merge 2 commits into
ngcpp:feature/v5from
mingxwa:user/mingxwa/construct
Closed

mingxwa wants to merge 2 commits into
ngcpp:feature/v5from
mingxwa:user/mingxwa/construct

Conversation

@mingxwa

@mingxwa mingxwa commented Nov 20, 2026

Copy link
Copy Markdown
Member

NOTE: Based on #111. Only the last commit is new.

  • 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 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, 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`.
- Added static assertions for the deleted destructor and the `swap` constraint, and a test that constructs such a `proxy` with a *new-expression*.
- 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 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, and a test that stores and copies a non-destructible pointer.
@mingxwa

mingxwa commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Squashed into #111, which now contains both changes.

@mingxwa mingxwa closed this Nov 21, 2026
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