[PATCH] PR libstdc++/98842: Fixed Constraints on operator<=>(optional, U)

Jonathan Wakely jwakely@redhat.com
Fri Jun 4 20:41:11 GMT 2021


On Thu, 3 Jun 2021 at 17:27, Seija K. via Libstdc++ <libstdc++@gcc.gnu.org>
wrote:

> The original operator was underconstrained. _Up needs to fulfill
> compare_three_way_result,
> as mentioned in this bug report
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98842
>

Thanks, I'll get the patch applied next week.



> diff --git a/libstdc++-v3/include/std/optional
> b/libstdc++-v3/include/std/optional
> index 8b9e038e6e510..9e61c1b2cbfbd 100644
> --- a/libstdc++-v3/include/std/optional
> +++ b/libstdc++-v3/include/std/optional
> @@ -1234,7 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      { return !__rhs || __lhs >= *__rhs; }
>
>  #ifdef __cpp_lib_three_way_comparison
> -  template<typename _Tp, typename _Up>
> +  template<typename _Tp, three_way_comparable_with<_Tp> _Up>
>      constexpr compare_three_way_result_t<_Tp, _Up>
>      operator<=>(const optional<_Tp>& __x, const _Up& __v)
>      { return bool(__x) ? *__x <=> __v : strong_ordering::less; }
>
>


More information about the Gcc-patches mailing list