Skip to content

Commit

Permalink
Added error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
H-G-Hristov committed Jul 17, 2024
1 parent 4d9dc5e commit 409f66a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions libcxx/include/__memory/inout_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_));
}
Expand All @@ -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<void**>(static_cast<_Pointer*>(*this));
}
Expand Down
8 changes: 5 additions & 3 deletions libcxx/include/__memory/out_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand All @@ -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_));
}
Expand All @@ -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<void**>(static_cast<_Pointer*>(*this));
}
Expand Down

0 comments on commit 409f66a

Please sign in to comment.