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

P2602R2 Poison Pills Are Too Toxic #3215

Merged
merged 3 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
48 changes: 24 additions & 24 deletions stl/inc/compare
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ namespace _Strong_order {
void strong_order(); // Block unqualified name lookup; see GH-1374.
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved

template <class _Ty1, class _Ty2>
concept _Has_ADL =
requires(_Ty1& _Left, _Ty2& _Right) { static_cast<strong_ordering>(/* ADL */ strong_order(_Left, _Right)); };
concept _Has_ADL = requires(_Ty1& _Left, _Ty2& _Right) {
static_cast<strong_ordering>(strong_order(_Left, _Right)); // intentional ADL
};

template <class _Ty1, class _Ty2>
concept _Can_compare_three_way =
Expand All @@ -380,7 +381,7 @@ namespace _Strong_order {
return {_St::_None};
} else if constexpr (_Has_ADL<_Ty1, _Ty2>) {
return {_St::_Adl, noexcept(static_cast<strong_ordering>(
/* ADL */ strong_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))};
strong_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))}; // intentional ADL
} else if constexpr (floating_point<decay_t<_Ty1>>) {
return {_St::_Floating, true};
} else if constexpr (_Can_compare_three_way<_Ty1, _Ty2>) {
Expand All @@ -401,7 +402,7 @@ namespace _Strong_order {
noexcept(_Choice<_Ty1&, _Ty2&>._No_throw) {
constexpr _St _Strat = _Choice<_Ty1&, _Ty2&>._Strategy;
if constexpr (_Strat == _St::_Adl) {
return static_cast<strong_ordering>(/* ADL */ strong_order(_Left, _Right));
return static_cast<strong_ordering>(strong_order(_Left, _Right)); // intentional ADL
} else if constexpr (_Strat == _St::_Floating) {
using _Floating_type = decay_t<_Ty1>;
using _Traits = _Floating_type_traits<_Floating_type>;
Expand Down Expand Up @@ -454,8 +455,9 @@ namespace _Weak_order {
void weak_order(); // Block unqualified name lookup; see GH-1374.

template <class _Ty1, class _Ty2>
concept _Has_ADL =
requires(_Ty1& _Left, _Ty2& _Right) { static_cast<weak_ordering>(/* ADL */ weak_order(_Left, _Right)); };
concept _Has_ADL = requires(_Ty1& _Left, _Ty2& _Right) {
static_cast<weak_ordering>(weak_order(_Left, _Right)); // intentional ADL
};

template <class _Ty1, class _Ty2>
concept _Can_compare_three_way =
Expand All @@ -474,16 +476,15 @@ namespace _Weak_order {
return {_St::_None};
} else if constexpr (_Has_ADL<_Ty1, _Ty2>) {
return {_St::_Adl, noexcept(static_cast<weak_ordering>(
/* ADL */ weak_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))};
weak_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))}; // intentional ADL
} else if constexpr (floating_point<decay_t<_Ty1>>) {
return {_St::_Floating, true};
} else if constexpr (_Can_compare_three_way<_Ty1, _Ty2>) {
return {_St::_Three, noexcept(static_cast<weak_ordering>(
compare_three_way{}(_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))};
} else if constexpr (_Strong_order::_Has_ADL<_Ty1, _Ty2>) {
return {_St::_Strong, noexcept(static_cast<weak_ordering>(static_cast<strong_ordering>(
/* ADL, throughput optimization */ strong_order(
_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))))};
return {_St::_Strong, noexcept(static_cast<weak_ordering>(static_cast<strong_ordering>(strong_order(
_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))))}; // intentional ADL
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
} else {
return {_St::_None};
}
Expand All @@ -499,7 +500,7 @@ namespace _Weak_order {
noexcept(_Choice<_Ty1&, _Ty2&>._No_throw) {
constexpr _St _Strat = _Choice<_Ty1&, _Ty2&>._Strategy;
if constexpr (_Strat == _St::_Adl) {
return static_cast<weak_ordering>(/* ADL */ weak_order(_Left, _Right));
return static_cast<weak_ordering>(weak_order(_Left, _Right)); // intentional ADL
} else if constexpr (_Strat == _St::_Floating) {
using _Floating_type = decay_t<_Ty1>;
using _Traits = _Floating_type_traits<_Floating_type>;
Expand Down Expand Up @@ -554,7 +555,7 @@ namespace _Weak_order {
return static_cast<weak_ordering>(compare_three_way{}(_Left, _Right));
} else if constexpr (_Strat == _St::_Strong) {
return static_cast<weak_ordering>(
static_cast<strong_ordering>(/* ADL, throughput optimization */ strong_order(_Left, _Right)));
static_cast<strong_ordering>(strong_order(_Left, _Right))); // intentional ADL
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
}
Expand All @@ -570,8 +571,9 @@ namespace _Partial_order {
void partial_order(); // Block unqualified name lookup; see GH-1374.

template <class _Ty1, class _Ty2>
concept _Has_ADL =
requires(_Ty1& _Left, _Ty2& _Right) { static_cast<partial_ordering>(/* ADL */ partial_order(_Left, _Right)); };
concept _Has_ADL = requires(_Ty1& _Left, _Ty2& _Right) {
static_cast<partial_ordering>(partial_order(_Left, _Right)); // intentional ADL
};

template <class _Ty1, class _Ty2>
concept _Can_compare_three_way =
Expand All @@ -591,19 +593,17 @@ namespace _Partial_order {
if constexpr (!same_as<decay_t<_Ty1>, decay_t<_Ty2>>) {
return {_St::_None};
} else if constexpr (_Has_ADL<_Ty1, _Ty2>) {
return {_St::_Adl, noexcept(static_cast<partial_ordering>(
/* ADL */ partial_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))};
return {_St::_Adl, noexcept(static_cast<partial_ordering>(partial_order(
_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))}; // intentional ADL
} else if constexpr (_Can_compare_three_way<_Ty1, _Ty2>) {
return {_St::_Three, noexcept(static_cast<partial_ordering>(
compare_three_way{}(_STD declval<_Ty1&>(), _STD declval<_Ty2&>())))};
} else if constexpr (_Weak_order::_Has_ADL<_Ty1, _Ty2>) {
return {_St::_Weak,
noexcept(static_cast<partial_ordering>(static_cast<weak_ordering>(
/* ADL, throughput optimization */ weak_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))))};
return {_St::_Weak, noexcept(static_cast<partial_ordering>(static_cast<weak_ordering>(
weak_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))))}; // intentional ADL
} else if constexpr (_Strong_order::_Has_ADL<_Ty1, _Ty2>) {
return {_St::_Strong, noexcept(static_cast<partial_ordering>(static_cast<strong_ordering>(
/* ADL, throughput optimization */ strong_order(
_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))))};
return {_St::_Strong, noexcept(static_cast<partial_ordering>(static_cast<strong_ordering>(strong_order(
_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))))}; // intentional ADL
} else {
return {_St::_None};
}
Expand All @@ -624,10 +624,10 @@ namespace _Partial_order {
return static_cast<partial_ordering>(compare_three_way{}(_Left, _Right));
} else if constexpr (_Strat == _St::_Weak) {
return static_cast<partial_ordering>(
static_cast<weak_ordering>(/* ADL, throughput optimization */ weak_order(_Left, _Right)));
static_cast<weak_ordering>(weak_order(_Left, _Right))); // intentional ADL
} else if constexpr (_Strat == _St::_Strong) {
return static_cast<partial_ordering>(
static_cast<strong_ordering>(/* ADL, throughput optimization */ strong_order(_Left, _Right)));
static_cast<strong_ordering>(strong_order(_Left, _Right))); // intentional ADL
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
}
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/concepts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ namespace ranges {
template <class _Ty1, class _Ty2>
concept _Use_ADL_swap = (_Has_class_or_enum_type<_Ty1> || _Has_class_or_enum_type<_Ty2>)
&& requires(_Ty1&& __t, _Ty2&& __u) {
swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u));
swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u)); // intentional ADL
};

struct _Cpo {
template <class _Ty1, class _Ty2>
requires _Use_ADL_swap<_Ty1, _Ty2>
constexpr void operator()(_Ty1&& __t, _Ty2&& __u) const
noexcept(noexcept(swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u)))) {
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u));
swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u)); // intentional ADL
}

template <class _Ty>
Expand Down
Loading