Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LWG-4144 Disallow unique_ptr<T&, D> #5201

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -3329,9 +3329,17 @@ template <class _Dx2>
using _Unique_ptr_enable_default_t =
enable_if_t<conjunction_v<negation<is_pointer<_Dx2>>, is_default_constructible<_Dx2>>, int>;

template <class, class = void>
constexpr bool _Can_form_pointer = false;
template <class _Ty>
constexpr bool _Can_form_pointer<_Ty, void_t<_Ty*>> = true;

_EXPORT_STD template <class _Ty, class _Dx /* = default_delete<_Ty> */>
class unique_ptr { // non-copyable pointer to an object
public:
static_assert(_Can_form_pointer<_Ty>,
"unique_ptr<T, D> requires T* to be a valid type (N5001 [unique.ptr.single.general]/1).");

using pointer = typename _Get_deleter_pointer_type<_Ty, remove_reference_t<_Dx>>::type;
using element_type = _Ty;
using deleter_type = _Dx;
Expand Down