This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4122. Ill-formed operator<=> can cause hard error when instantiating std::inplace_vector

Section: 24.3.14.1 [inplace.vector.overview] Status: New Submitter: Jiang An Opened: 2024-07-20 Last modified: 2024-08-02

Priority: 2

View all issues with New status.

Discussion:

This is almost the same problem as LWG 4071(i) except that it happens to std::inplace_vector. As the operator<=> overload for std::inplace_vector is a non-template function whose return type (synth-three-way-result<T>) is not deduced, when the return type is ill-formed, hard error occurs in the instantiation of the enclosing std::inplace_vector<T, N>.

[2024-08-02; Reflector poll]

Set priority to 2 after reflector poll.

Proposed resolution:

This wording is relative to N4986.

  1. Modify 24.3.14.1 [inplace.vector.overview], class template std::inplace_vector synopsis, as indicated:

    namespace std {
      template<class T, size_t N>
      class inplace_vector {
      public:
        […]
        constexpr friend bool operator==(const inplace_vector& x,
                                         const inplace_vector& y);
        constexpr friend synth-three-way-result<T>auto
          operator<=>(const inplace_vector& x, const inplace_vector& y);
            requires requires (const T t) { synth-three-way(t, t); } 
          {
            return lexicographical_compare_three_way(x.begin(), x.end(), y.begin(), y.end(),
                                                     synth-three-way);
          }
        constexpr friend void swap(inplace_vector& x, inplace_vector& y)
          noexcept(N == 0 || (is_nothrow_swappable_v<T> &&
                              is_nothrow_move_constructible_v<T>))
        { x.swap(y); }
      };
    };