On Mon, 16 Sept 2024 at 18:24, François Dumont wrote:
> Yes, my bad, I shouldn't have said that it was not SFINAE friendly. In the 
> patch you can see that I tried to move it as friend like this:
>
>       template<typename _Up>
>     [[nodiscard]] _GLIBCXX20_CONSTEXPR
>     friend inline enable_if_t<is_same_v<_Tp, _Up> &&
>                   three_way_comparable<_Up>,
>                   __detail::__synth3way_t<_Up>>
>     operator<=>(const vector<_Up, _Alloc>& __x,
>             const vector<_Up, _Alloc>& __y)

That would be wrong though, because the three_way_comparable<T>
constraint is not wanted. The whole point of synth-three-way is to
make <=> comparisons work for types that do not satisfy
three_way_comparable.

A correct change would be:

    template<same_as<_Tp> _Up>
    [[nodiscard]] _GLIBCXX20_CONSTEXPR
    friend inline __detail::__synth3way_t<_Up>
    operator<=>(const vector<_Up, _Alloc>& __x,
                const vector<_Up, _Alloc>& __y)

Or don't constrain it and just use:

    template<typename _Up = _Tp>
    [[nodiscard]] _GLIBCXX20_CONSTEXPR
    friend inline __detail::__synth3way_t<_Up>

This is the same problem as https://cplusplus.github.io/LWG/issue4071

N.B. the 'inline' keywords above are unnecessary. The friend function
is defined inline, so it's implicitly an inline function.

Reply via email to