From 409f66a36d5639588e0b818ea39fc88c45ff320d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 17 Jul 2024 17:23:45 +0300 Subject: [PATCH] Added error messages --- libcxx/include/__memory/inout_ptr.h | 5 +++-- libcxx/include/__memory/out_ptr.h | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libcxx/include/__memory/inout_ptr.h b/libcxx/include/__memory/inout_ptr.h index 04ba6a8a72ea85..72e1a21ad68671 100644 --- a/libcxx/include/__memory/inout_ptr.h +++ b/libcxx/include/__memory/inout_ptr.h @@ -71,7 +71,8 @@ class _LIBCPP_TEMPLATE_VIS inout_ptr_t { std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); }, std::move(__a_)); } else { - static_assert(is_constructible_v<_Smart, _SP, _Args...>); + static_assert(is_constructible_v<_Smart, _SP, _Args...>, + "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args..."); std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); }, std::move(__a_)); } @@ -82,7 +83,7 @@ class _LIBCPP_TEMPLATE_VIS inout_ptr_t { _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept requires(!is_same_v<_Pointer, void*>) { - static_assert(is_pointer_v<_Pointer>); + static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer."); return reinterpret_cast(static_cast<_Pointer*>(*this)); } diff --git a/libcxx/include/__memory/out_ptr.h b/libcxx/include/__memory/out_ptr.h index 139a181841e4a1..95aa2029c92314 100644 --- a/libcxx/include/__memory/out_ptr.h +++ b/libcxx/include/__memory/out_ptr.h @@ -46,7 +46,8 @@ class _LIBCPP_TEMPLATE_VIS out_ptr_t { } else if constexpr (is_constructible_v<_Smart>) { __s_ = _Smart(); } else { - static_assert(__resettable_smart_pointer<_Ptr> || is_constructible_v<_Smart>); + static_assert(__resettable_smart_pointer<_Ptr> || is_constructible_v<_Smart>, + "The adapted pointer type must have a reset() member function or be default constructible."); } } @@ -62,7 +63,8 @@ class _LIBCPP_TEMPLATE_VIS out_ptr_t { std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); }, std::move(__a_)); } else { - static_assert(is_constructible_v<_Smart, _SP, _Args...>); + static_assert(is_constructible_v<_Smart, _SP, _Args...>, + "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args..."); std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); }, std::move(__a_)); } @@ -73,7 +75,7 @@ class _LIBCPP_TEMPLATE_VIS out_ptr_t { _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept requires(!is_same_v<_Pointer, void*>) { - static_assert(is_pointer_v<_Pointer>); + static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer."); return reinterpret_cast(static_cast<_Pointer*>(*this)); }