-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++] Make forward_list constexpr as part of P3372R3 #129435
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
Changes from all commits
838c50f
3d213b1
b6fd6de
a5b63dd
7c90175
6b7800a
30daee8
1b3743e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,8 +245,8 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept { | |
} | ||
|
||
template <class _Pointer> | ||
inline _LIBCPP_HIDE_FROM_ABI constexpr auto | ||
to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) { | ||
inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(const _Pointer& __p) noexcept | ||
-> decltype(std::__to_address(__p)) { | ||
return std::__to_address(__p); | ||
} | ||
#endif | ||
|
@@ -302,6 +302,18 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p | |
|
||
#endif | ||
|
||
// This function ensures safe conversions between fancy pointers at compile-time, where we avoid casts from/to | ||
// `__void_pointer` by obtaining the underlying raw pointer from the fancy pointer using `std::to_address`, | ||
// then dereferencing it to retrieve the pointed-to object, and finally constructing the target fancy pointer | ||
// to that object using the `std::pointer_traits<>::pinter_to` function. | ||
template <class _PtrTo, class _PtrFrom> | ||
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) { | ||
|
||
using __ptr_traits = pointer_traits<_PtrTo>; | ||
using __element_type = typename __ptr_traits::element_type; | ||
return __p ? __ptr_traits::pointer_to(*static_cast<__element_type*>(std::addressof(*__p))) | ||
: static_cast<_PtrTo>(nullptr); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
_LIBCPP_POP_MACROS | ||
|
Uh oh!
There was an error while loading. Please reload this page.