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

[libc++] Use a different smart ptr type alias #102089

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
10 changes: 5 additions & 5 deletions libcxx/include/__memory/inout_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ class _LIBCPP_TEMPLATE_VIS inout_ptr_t {
}
}

using _SP = __pointer_of_or_t<_Smart, _Pointer>;
using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
if constexpr (is_pointer_v<_Smart>) {
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
} else if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
} else {
static_assert(is_constructible_v<_Smart, _SP, _Args...>,
static_assert(is_constructible_v<_Smart, _SmartPtr, _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::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
}
}
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/__memory/out_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ class _LIBCPP_TEMPLATE_VIS out_ptr_t {
return;
}

using _SP = __pointer_of_or_t<_Smart, _Pointer>;
using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
} else {
static_assert(is_constructible_v<_Smart, _SP, _Args...>,
static_assert(is_constructible_v<_Smart, _SmartPtr, _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::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
}
}
Expand Down
18 changes: 16 additions & 2 deletions libcxx/test/libcxx/system_reserved_names.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from libcxx.header_information import lit_header_restrictions, public_headers

for header in public_headers:
print(f"""\
print(
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}

Expand Down Expand Up @@ -162,6 +163,18 @@
#define erase SYSTEM_RESERVED_NAME
#define refresh SYSTEM_RESERVED_NAME

// Dinkumware libc ctype.h uses these definitions
#define _XA SYSTEM_RESERVED_NAME
#define _XS SYSTEM_RESERVED_NAME
#define _BB SYSTEM_RESERVED_NAME
#define _CN SYSTEM_RESERVED_NAME
#define _DI SYSTEM_RESERVED_NAME
#define _LO SYSTEM_RESERVED_NAME
#define _PU SYSTEM_RESERVED_NAME
#define _SP SYSTEM_RESERVED_NAME
#define _UP SYSTEM_RESERVED_NAME
#define _XD SYSTEM_RESERVED_NAME

#include <{header}>

// Make sure we don't swallow the definition of the macros we push/pop
Expand All @@ -172,4 +185,5 @@
static_assert(__builtin_strcmp(STRINGIFY(move), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
static_assert(__builtin_strcmp(STRINGIFY(erase), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
static_assert(__builtin_strcmp(STRINGIFY(refresh), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
""")
"""
)
Loading