It seems that the patch is causing *first to be moved twice into the same position. *first is already moved in the __stable_partition_adaptive function: if (__len <= __buffer_size) { _ForwardIterator __result1 = __first; _Pointer __result2 = __buffer;
// The precondition guarantees that !__pred(__first), so // move that element to the buffer before starting the loop. // This ensures that we only call __pred once per element. *__result2 = _GLIBCXX_MOVE(*__first); <--- moved here And your patch moves the same element when creating buffer: #if __glibcxx_constexpr_algorithms >= 202306L // >= C++26 if consteval { _ValueType __buf = std::move(*__first); return std::__stable_partition_adaptive(__first, __last, __pred, __len, &__buf, _DistanceType(1)); } +#endif Given that we have constexpr allocations now, do we really need to avoid allocating temporary buffers, and using very slow implementation? On Sat, Mar 15, 2025 at 9:15 PM Giuseppe D'Angelo <giuseppe.dang...@kdab.com> wrote: > Hello, > > I'm attaching the patch for constexpr stable_partition. > > Thank you, > -- > Giuseppe D'Angelo >