Title
Ill-formed operator<=> can cause hard error when instantiating std::inplace_vector
Status
new
Section
[inplace.vector.overview]
Submitter
Jiang An

Created on 2024-07-20.00:00:00 last changed 1 month ago

Messages

Date: 2024-08-02.21:14:44

Proposed resolution:

This wording is relative to N4986.

  1. Modify [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); }
      };
    };
    
Date: 2024-08-15.00:00:00

[ 2024-08-02; Reflector poll ]

Set priority to 2 after reflector poll.

Date: 2024-07-20.00:00:00

This is almost the same problem as LWG 4071 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>.

History
Date User Action Args
2024-08-02 21:14:44adminsetmessages: + msg14283
2024-07-21 09:47:10adminsetmessages: + msg14260
2024-07-20 00:00:00admincreate