Skip to content

[libc++] Simplify the implementation of LWG2762 (noexcept for unique_ptr) #102032

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

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 1 addition & 13 deletions libcxx/include/__memory/unique_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <__type_traits/is_trivially_relocatable.h>
#include <__type_traits/is_void.h>
#include <__type_traits/remove_extent.h>
#include <__type_traits/remove_pointer.h>
#include <__type_traits/type_identity.h>
#include <__utility/declval.h>
#include <__utility/forward.h>
Expand All @@ -52,17 +51,6 @@ _LIBCPP_PUSH_MACROS

_LIBCPP_BEGIN_NAMESPACE_STD

#ifndef _LIBCPP_CXX03_LANG

template <class _Ptr>
struct __is_noexcept_deref_or_void {
static constexpr bool value = noexcept(*std::declval<_Ptr>());
};

template <>
struct __is_noexcept_deref_or_void<void*> : true_type {};
#endif

template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS default_delete {
static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");
Expand Down Expand Up @@ -266,7 +254,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
}

_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const
_NOEXCEPT_(__is_noexcept_deref_or_void<pointer>::value) {
_NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) {
return *__ptr_.first();
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,3 @@ static_assert(std::indirectly_movable_storable<std::unique_ptr<int>, std::unique
static_assert(std::indirectly_copyable<std::unique_ptr<int>, std::unique_ptr<int>>);
static_assert(std::indirectly_copyable_storable<std::unique_ptr<int>, std::unique_ptr<int>>);
static_assert(std::indirectly_swappable<std::unique_ptr<int>, std::unique_ptr<int> >);

static_assert(!std::indirectly_readable<std::unique_ptr<void> >);
static_assert(!std::indirectly_writable<std::unique_ptr<void>, void>);
static_assert(!std::weakly_incrementable<std::unique_ptr<void> >);
static_assert(!std::indirectly_movable<std::unique_ptr<void>, std::unique_ptr<void>>);
static_assert(!std::indirectly_movable_storable<std::unique_ptr<void>, std::unique_ptr<void>>);
static_assert(!std::indirectly_copyable<std::unique_ptr<void>, std::unique_ptr<void>>);
static_assert(!std::indirectly_copyable_storable<std::unique_ptr<void>, std::unique_ptr<void>>);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ struct Deleter {
#endif

TEST_CONSTEXPR_CXX23 bool test() {
ASSERT_NOEXCEPT(*(std::unique_ptr<void>{}));
#if TEST_STD_VER >= 11
static_assert(noexcept(*std::declval<std::unique_ptr<void>>()), "");
#endif
{
std::unique_ptr<int> p(new int(3));
assert(*p == 3);
Expand Down
Loading