Now that your part is in here is the new patch for the small cleanup left.

    libstdc++: std::inplace_vector implementation cleaup

    Remove duplicated std::swap implementations.

    libstdc++-v3/ChangeLog

            * include/std/inplace_vector:
            (std::swap(inplace_vector<>&, inplace_vector<>&)): Remove the duplicated             implementation at std namespace level. Keep the friend inline one.             (inplace_vector<Tp, 0>::assign(initializer_list<>): Add missing return
            statement.


Tested under Linux x86_64,

ok to commit ?

François


On 9/22/25 20:04, Jonathan Wakely wrote:
On Mon, 22 Sept 2025 at 18:15, François Dumont <[email protected]> wrote:
Some minor points spotted while working on the _GLIBCXX_DEBUG
implementation.

I'm surprised that gcc did not complained about the duplicated std::swap
implementation. He seems to be smart enough to see that it is the same
despite the different noexcept qualification.
No, they're not the same. The friend one is a non-template function
which is defined for every std::inplace_vector specialization, and the
one at namespace scope is a function template.

It's still correct to remove the one at namespace scope, but GCC is
right to not complain.

      libstdc++: std::inplace_vector implementation cleaup

      Remove duplicated std::swap implementations.

      Remove use of std::ref in std::erase_if.

      libstdc++-v3/ChangeLog

              * include/std/inplace_vector: Remove refwrap.h include.
              (std::swap(inplace_vector<>&, inplace_vector<>&)): Remove
the duplicated
              implementation at std namespace level. Keep the friend
inline one.
              (std::erase_if): Remove std::ref usage.

23_containers/inplace_vector tests run under Linux x86_64.

Ok to commit ?
No, I'm already changing erase_if and erase in
https://forge.sourceware.org/gcc/gcc-TEST/pulls/78/commits/4d4a7dd885afca17a526caf504463310b3159587
which I'm about to push.
diff --git a/libstdc++-v3/include/std/inplace_vector 
b/libstdc++-v3/include/std/inplace_vector
index 91ceace08f5..7aa6f9d4ab2 100644
--- a/libstdc++-v3/include/std/inplace_vector
+++ b/libstdc++-v3/include/std/inplace_vector
@@ -823,6 +823,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                                      __detail::__synth3way);
       }
 
+      // [inplace.vector.special], specialized algorithms
       constexpr friend void
       swap(inplace_vector& __x, inplace_vector& __y)
       noexcept(is_nothrow_swappable_v<_Tp> && 
is_nothrow_move_constructible_v<_Tp>)
@@ -907,13 +908,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
     };
 
-  // [inplace.vector.special], specialized algorithms
-  template<typename _Tp, size_t _Nm>
-    constexpr void
-    swap(inplace_vector<_Tp, _Nm>& __x, inplace_vector<_Tp, _Nm>& __y)
-    noexcept(noexcept(__x.swap(__y)))
-    { __x.swap(__y); }
-
   // specialization for zero capacity, that is required to be trivally copyable
   // and empty regardless of _Tp.
   template<typename _Tp>
@@ -992,6 +986,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
        if (__il.size() != 0)
          __throw_bad_alloc();
+       return *this;
       }
 
       template<__any_input_iterator _InputIterator>

Reply via email to