On 9/14/26 19:28, Jonathan Wakely wrote:
On Mon, 14 Sept 2026 at 18:19, François Dumont<[email protected]> wrote:
Hi

On a previous patch Jonathan spotted that in _GLIBCXX_DEBUG
implementation of inplace_vector we could use the builtin constant
evaluated checks rather than the library equivalent.

So here is this simplification outside any patch.

      libstdc++: [_GLIBCXX_DEBUG] Simplify constant-evaluated checks

      In the C++26std::__debug::inplace_vector implementation we can use:

      if consteval
      {
        ...
      }
Everywhere else (well, almost everywhere) we put the opening brace on
the same line as 'if consteval'

I won't use this 'almost' as an excuse.

Now fixed, sorry.

    libstdc++: [_GLIBCXX_DEBUG] Fix coding style on if consteval

    Coding style imposes curly brasses to be open on same line, like this:

    if consteval {
      ....
    }

    libstdc++-v3/ChangeLog:

            * include/debug/inplace_vector: Apply proper coding style on all
            'if consteval' expressions.

      rather than:

      if (std::is_constant_evaluated())

      libstdc++-v3/ChangeLog:

              * include/debug/inplace_vector
              (inplace_vector::emplace): Replace usages of
std::is_constant_evaluated
              by consteval.
              (inplace_vector::insert): Likewise.
              (inplace_vector::erase): Likewise.

Tested under Linux x86_64 _GLIBCXX_DEBUG mode.

2 tests are already failing on master, I'm working on this independently
of this patch.

François
diff --git a/libstdc++-v3/include/debug/inplace_vector 
b/libstdc++-v3/include/debug/inplace_vector
index a0bf4c85442..3dc26d476a2 100644
--- a/libstdc++-v3/include/debug/inplace_vector
+++ b/libstdc++-v3/include/debug/inplace_vector
@@ -400,8 +400,7 @@ namespace __debug
        constexpr iterator
        emplace(const_iterator __position, _Args&&... __args)
        {
-         if consteval
-           {
+         if consteval {
              return iterator(_Base::emplace(__position.base(),
                                             std::forward<_Args>(__args)...),
                              this);
@@ -426,8 +425,7 @@ namespace __debug
       constexpr iterator
       insert(const_iterator __position, size_type __n, const _Tp& __x)
       {
-       if consteval
-         {
+       if consteval {
            return iterator(_Base::insert(__position.base(), __n, __x), this);
          }
 
@@ -443,8 +441,7 @@ namespace __debug
        insert(const_iterator __position, _InputIterator __first,
               _InputIterator __last)
        {
-         if consteval
-           {
+         if consteval {
              return iterator(_Base::insert(__position.base(),
                                            __gnu_debug::__unsafe(__first),
                                            __gnu_debug::__unsafe(__last)),
@@ -483,8 +480,7 @@ namespace __debug
       constexpr iterator
       insert(const_iterator __position, initializer_list<_Tp> __il)
       {
-       if consteval
-         {
+       if consteval {
            return iterator(_Base::insert(__position.base(), __il), this);
          }
 
@@ -500,8 +496,7 @@ namespace __debug
       constexpr iterator
       erase(const_iterator __position)
       {
-       if consteval
-         {
+       if consteval {
            return iterator(_Base::erase(__position.base()), this);
          }
 
@@ -515,8 +510,7 @@ namespace __debug
       constexpr iterator
       erase(const_iterator __first, const_iterator __last)
       {
-       if consteval
-         {
+       if consteval {
            return iterator(_Base::erase(__first.base(), __last.base()),
                            this);
          }

Reply via email to