On Thu, 22 Oct 2026 at 12:35, Jonathan Wakely <[email protected]> wrote:
>
> On Thu, 22 Oct 2026 at 02:54, Mishmish Dev <[email protected]> wrote:
> >
> > On the gcc-16 branch, with -freflection and -D_GLIBCXX_DEBUG, most
> > operations on std::vector<std::meta::info> fail in constant expressions
> > with errors such as:
> >
> >   error: function of consteval-only type must be declared 'consteval'
> >   error: consteval-only expressions are only allowed in a
> >   constant-evaluated context
> >
> > On this branch std::meta::info is a consteval-only type, so Debug Mode
> > formatter and iterator helpers instantiated for it have consteval-only
> > function types.  This patch marks them constexpr so those instantiations
> > can undergo immediate escalation.
> >
> > Use _GLIBCXX20_CONSTEXPR where a valid constant-evaluation path exists and
> > _GLIBCXX23_CONSTEXPR for helpers that only run at runtime (attaching
> > iterators, the error formatter).
> >
> > This patch is for releases/gcc-16 only.  Trunk implements P4101
> > (consteval-only values, r17-4197-g127bd0f4082), under which these helpers
> > no longer have consteval-only types, and all static assertions from the new
> > testcase compile. (https://godbolt.org/z/W4n3GYd6d)
>
> This is a fairly large patch to carry only on the branch and not on trunk.
>
> Why does reflection need additional functions and types to be
> instantiated which are not needed for non-reflection constant
> expressions?
>
> For example, this compiles OK:
>
> #define _GLIBCXX_DEBUG
> #include <vector>
>
> consteval bool f()
> {
>   std::vector<int> v{1,2,3,4};
>   auto it = v.begin();
>   ++it;
>   return *it++ == 2;
> }
> static_assert( f() );
>
> Is it just that every member function of a consteval-only type must be
> constexpr, even the ones that are never actually constant evaluated?
>
> I think a better solution would be for reflection to always use the
> non-debug vector. There's no benefit to using the debug mode vector
> during constant evaluation.
>
> So:
>
> --- a/libstdc++-v3/include/std/meta
> +++ b/libstdc++-v3/include/std/meta
> @@ -84,6 +84,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>
>   namespace meta
>   {
> +    using _GLIBCXX_STD_C::vector;
> +
>     using info = decltype(^^int);
>
>     // [meta.reflection.exception], class exception
>
> The downside of this change is that code using <meta> needs to also
> refer to _GLIBCXX_STD_C::vector (or std::meta::vector) to get the
> non-debug mode vector that will be returned by reflection functions in
> <meta>.

Alternatively, we could just make _GLIBCXX_DEBUG have no effect (for
gcc-16) if __cpp_reflection is defined.

That would mean all code compiles OK, you just don't get the debug
iterators in a program that also uses reflection. That seems like the
smallest and least invasive change for gcc-16.

For trunk, it already works fine and no change is needed, you can use
debug mode and reflection in the same program.

>
>
> >
> >         PR c++/124312
> >
> > libstdc++-v3/ChangeLog:
> >
> >         * include/debug/formatter.h (_Error_formatter::_Parameter): Add
> >         constexpr to the iterator and sequence constructors.
> >         (_Error_formatter::_Parameter::_S_reverse_state)
> >         (_Error_formatter::_M_iterator, _Error_formatter::_M_sequence): Add
> >         constexpr.
> >         * include/debug/safe_iterator.h (_BeforeBeginHelper::_S_Is)
> >         (_Sequence_traits::_S_size, _Safe_iterator::_M_attach)
> >         (_Safe_iterator::_M_dereferenceable)
> >         (_Safe_iterator::_M_incrementable)
> >         (_Safe_iterator::_M_value_initialized)
> >         (_Safe_iterator::_M_can_advance, _Safe_iterator::_M_get_sequence)
> >         (_Safe_iterator::_M_get_distance_from_begin)
> >         (_Safe_iterator::_M_get_distance_to_end, _Safe_iterator::_M_is_end)
> >         (_Safe_iterator::_M_is_before_begin)
> >         (_Safe_iterator::_M_decrementable)
> >         (_Safe_iterator::_M_valid_range): Likewise.
> >         * include/debug/safe_iterator.tcc (_Safe_iterator::_M_can_advance)
> >         (_Safe_iterator::_M_get_distance_from_begin)
> >         (_Safe_iterator::_M_get_distance_to_end)
> >         (_Safe_iterator::_M_valid_range): Likewise.
> >         * include/debug/safe_sequence.h (_Equal_to::operator())
> >         (_After_nth_from::operator())
> >         (_Safe_sequence::_M_invalidate_if_impl): Likewise.
> >         * include/debug/safe_sequence.tcc
> >         (_Safe_sequence::_M_invalidate_if_impl): Likewise.
> >         * include/debug/vector (_Safe_vector::_M_requires_reallocation)
> >         (vector::_M_invalidate_after_nth): Likewise.
> >         * testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
> >         Adjust expected line number.
> >         * testsuite/23_containers/vector/debug/124312.cc: New test.
> > Signed-off-by: Mishmish Dev <[email protected]>
> > ---
> > Tested on ARM64 Debian 13, branch releases/gcc-16 at cce25db4b9117.
> > The full libstdc++ testsuite was run before and after this patch with
> > GLIBCXX_TESTSUITE_STDS=20,26.
> >
> > No regressions.  The only outcome change is FAIL to PASS for the added
> > test in 124312.cc.  The new test contains 16 static assertions.
> >
> > This patch does not fully resolve PR124312.  The original example from
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124312 fails with
> > _GLIBCXX_DEBUG because of a separate compiler front-end issue
> > affecting both gcc-16 and trunk.  On gcc-16, range insertion of
> > std::meta::info into std::vector and std::inplace_vector also fails:
> > the __foreign_iterator helpers that check iterator ownership and the
> > __unsafe overload that unwraps Debug Mode iterators are not constexpr.
> > I plan to address these remaining issues in subsequent submissions.
> >
> >
> >  libstdc++-v3/include/debug/formatter.h             |   13 ++
> >  libstdc++-v3/include/debug/safe_iterator.h         |   15 ++
> >  libstdc++-v3/include/debug/safe_iterator.tcc       |    5 +
> >  libstdc++-v3/include/debug/safe_sequence.h         |    3
> >  libstdc++-v3/include/debug/safe_sequence.tcc       |    1
> >  libstdc++-v3/include/debug/vector                  |    2
> >  .../vector/cons/destructible_debug_neg.cc          |    2
> >  .../testsuite/23_containers/vector/debug/124312.cc |  131 
> > ++++++++++++++++++++
> >  8 files changed, 171 insertions(+), 1 deletion(-)
> >
> > diff --git a/libstdc++-v3/include/debug/formatter.h 
> > b/libstdc++-v3/include/debug/formatter.h
> > index ca3a48a4030..07cfe5e6e81 100644
> > --- a/libstdc++-v3/include/debug/formatter.h
> > +++ b/libstdc++-v3/include/debug/formatter.h
> > @@ -284,6 +284,7 @@
> >        }
> >
> >        template<typename _Iterator, typename _Sequence, typename _Category>
> > +       _GLIBCXX23_CONSTEXPR
> >         _Parameter(_Safe_iterator<_Iterator, _Sequence, _Category> const& 
> > __it,
> >                    const char* __name, _Is_iterator)
> >         : _M_kind(__iterator),  _M_variant()
> > @@ -348,6 +349,7 @@
> >         }
> >
> >        template<typename _Type>
> > +       _GLIBCXX20_CONSTEXPR
> >         _Parameter(const _Type* const& __it, const char* __name, 
> > _Is_iterator)
> >         : _M_kind(__iterator), _M_variant()
> >         {
> > @@ -361,6 +363,7 @@
> >         }
> >
> >        template<typename _Type>
> > +       _GLIBCXX20_CONSTEXPR
> >         _Parameter(_Type* const& __it, const char* __name, _Is_iterator)
> >         : _M_kind(__iterator), _M_variant()
> >         {
> > @@ -374,6 +377,7 @@
> >         }
> >
> >        template<typename _Iterator>
> > +       _GLIBCXX20_CONSTEXPR
> >         _Parameter(_Iterator const& __it, const char* __name, _Is_iterator)
> >         : _M_kind(__iterator), _M_variant()
> >         {
> > @@ -391,6 +395,7 @@
> >        // The following constructors are only defined in C++11 to take
> >        // advantage of the constructor delegation feature.
> >        template<typename _Iterator, typename _Container>
> > +        _GLIBCXX20_CONSTEXPR
> >          _Parameter(
> >           __gnu_cxx::__normal_iterator<_Iterator, _Container> const& __it,
> >         const char* __name, _Is_iterator)
> > @@ -398,6 +403,7 @@
> >         { _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); }
> >
> >        template<typename _Iterator>
> > +       _GLIBCXX20_CONSTEXPR
> >         _Parameter(std::reverse_iterator<_Iterator> const& __it,
> >                    const char* __name, _Is_iterator)
> >         : _Parameter(__it.base(), __name, _Is_iterator{})
> > @@ -408,6 +414,7 @@
> >         }
> >
> >        template<typename _Iterator, typename _Sequence, typename _Category>
> > +       _GLIBCXX23_CONSTEXPR
> >         _Parameter(std::reverse_iterator<_Safe_iterator<_Iterator, 
> > _Sequence,
> >                                                         _Category>> const& 
> > __it,
> >           const char* __name, _Is_iterator)
> > @@ -420,12 +427,14 @@
> >         }
> >
> >        template<typename _Iterator>
> > +       _GLIBCXX20_CONSTEXPR
> >         _Parameter(std::move_iterator<_Iterator> const& __it,
> >                    const char* __name, _Is_iterator)
> >         : _Parameter(__it.base(), __name, _Is_iterator{})
> >         { _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); }
> >
> >        template<typename _Iterator, typename _Sequence, typename _Category>
> > +       _GLIBCXX23_CONSTEXPR
> >         _Parameter(std::move_iterator<_Safe_iterator<_Iterator, _Sequence,
> >                                                      _Category>> const& 
> > __it,
> >           const char* __name, _Is_iterator)
> > @@ -436,6 +445,7 @@
> >        }
> >
> >      private:
> > +      _GLIBCXX20_CONSTEXPR
> >        _Iterator_state
> >        _S_reverse_state(_Iterator_state __state)
> >        {
> > @@ -467,6 +477,7 @@
> >         }
> >
> >        template<typename _Sequence>
> > +       _GLIBCXX20_CONSTEXPR
> >         _Parameter(const _Sequence& __seq, const char* __name, _Is_sequence)
> >         : _M_kind(__sequence), _M_variant()
> >         {
> > @@ -506,6 +517,7 @@
> >      };
> >
> >      template<typename _Iterator>
> > +      _GLIBCXX23_CONSTEXPR
> >        _Error_formatter&
> >        _M_iterator(const _Iterator& __it, const char* __name = 0)
> >        {
> > @@ -543,6 +555,7 @@
> >      }
> >
> >      template<typename _Sequence>
> > +      _GLIBCXX23_CONSTEXPR
> >        _Error_formatter&
> >        _M_sequence(const _Sequence& __seq, const char* __name = 0)
> >        {
> > diff --git a/libstdc++-v3/include/debug/safe_iterator.h 
> > b/libstdc++-v3/include/debug/safe_iterator.h
> > index 77e45ae073e..f2998547560 100644
> > --- a/libstdc++-v3/include/debug/safe_iterator.h
> > +++ b/libstdc++-v3/include/debug/safe_iterator.h
> > @@ -88,6 +88,7 @@
> >      struct _BeforeBeginHelper
> >      {
> >        template<typename _Iterator, typename _Category>
> > +       _GLIBCXX20_CONSTEXPR
> >         static bool
> >         _S_Is(const _Safe_iterator<_Iterator, _Sequence, _Category>&)
> >         { return false; }
> > @@ -104,6 +105,7 @@
> >      {
> >        typedef _Distance_traits<typename _Sequence::iterator> _DistTraits;
> >
> > +      _GLIBCXX20_CONSTEXPR
> >        static typename _DistTraits::__type
> >        _S_size(const _Sequence& __seq)
> >        { return std::make_pair(__seq.size(), __dp_exact); }
> > @@ -444,6 +446,7 @@
> >        operator _Iterator() const _GLIBCXX_NOEXCEPT { return *this; }
> >
> >        /** Attach iterator to the given sequence. */
> > +      _GLIBCXX23_CONSTEXPR
> >        void
> >        _M_attach(const _Safe_sequence_base* __seq)
> >        { _Safe_base::_M_attach(__seq, _S_constant()); }
> > @@ -454,6 +457,7 @@
> >        { _Safe_base::_M_attach_single(__seq, _S_constant()); }
> >
> >        /// Is the iterator dereferenceable?
> > +      _GLIBCXX23_CONSTEXPR
> >        bool
> >        _M_dereferenceable() const
> >        { return !this->_M_singular() && !_M_is_end() && 
> > !_M_is_before_begin(); }
> > @@ -471,21 +475,25 @@
> >        }
> >
> >        /// Is the iterator incrementable?
> > +      _GLIBCXX23_CONSTEXPR
> >        bool
> >        _M_incrementable() const
> >        { return !this->_M_singular() && !_M_is_end(); }
> >
> >        /// Is the iterator value-initialized?
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        _M_value_initialized() const
> >        { return _M_version == 0 && base() == _Iter_base(); }
> >
> >        // Can we advance the iterator @p __n steps (@p __n may be negative)
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        _M_can_advance(difference_type __n, bool __strict = false) const;
> >
> >        // Can we advance the iterator using @p __dist in @p __way direction.
> >        template<typename _Diff>
> > +       _GLIBCXX20_CONSTEXPR
> >         bool
> >         _M_can_advance(const std::pair<_Diff, _Distance_precision>& __dist,
> >                        int __way) const;
> > @@ -497,6 +505,7 @@
> >                      bool __check_dereferenceable = true) const;
> >
> >        // The sequence this iterator references.
> > +      _GLIBCXX20_CONSTEXPR
> >        typename __gnu_cxx::__conditional_type<
> >         _IsConstant::__value, const _Sequence*, _Sequence*>::__type
> >        _M_get_sequence() const
> > @@ -513,10 +522,12 @@
> >        _M_get_distance_to(const _Safe_iterator& __rhs) const;
> >
> >        // Get distance from sequence begin up to *this.
> > +      _GLIBCXX20_CONSTEXPR
> >        typename _Distance_traits<_Iterator>::__type
> >        _M_get_distance_from_begin() const;
> >
> >        // Get distance from *this to sequence end.
> > +      _GLIBCXX20_CONSTEXPR
> >        typename _Distance_traits<_Iterator>::__type
> >        _M_get_distance_to_end() const;
> >
> > @@ -527,12 +538,14 @@
> >        { return base() == _M_get_sequence()->_M_base().begin(); }
> >
> >        /// Is this iterator equal to the sequence's end() iterator?
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        _M_is_end() const
> >        { return base() == _M_get_sequence()->_M_base().end(); }
> >
> >        /// Is this iterator equal to the sequence's before_begin() iterator 
> > if
> >        /// any?
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        _M_is_before_begin() const
> >        { return _BeforeBeginHelper<_Sequence>::_S_Is(*this); }
> > @@ -744,6 +757,7 @@
> >        // ------ Utilities ------
> >
> >        // Is the iterator decrementable?
> > +      _GLIBCXX23_CONSTEXPR
> >        bool
> >        _M_decrementable() const
> >        { return !this->_M_singular() && !this->_M_is_begin(); }
> > @@ -838,6 +852,7 @@
> >  #endif
> >
> >        // Is the iterator range [*this, __rhs) valid?
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        _M_valid_range(const _Safe_iterator& __rhs,
> >                      std::pair<difference_type,
> > diff --git a/libstdc++-v3/include/debug/safe_iterator.tcc 
> > b/libstdc++-v3/include/debug/safe_iterator.tcc
> > index 715eceb92f3..55006ef0101 100644
> > --- a/libstdc++-v3/include/debug/safe_iterator.tcc
> > +++ b/libstdc++-v3/include/debug/safe_iterator.tcc
> > @@ -34,6 +34,7 @@
> >  namespace __gnu_debug
> >  {
> >    template<typename _Iterator, typename _Sequence, typename _Category>
> > +    _GLIBCXX20_CONSTEXPR
> >      typename _Distance_traits<_Iterator>::__type
> >      _Safe_iterator<_Iterator, _Sequence, _Category>::
> >      _M_get_distance_from_begin() const
> > @@ -58,6 +59,7 @@
> >      }
> >
> >    template<typename _Iterator, typename _Sequence, typename _Category>
> > +    _GLIBCXX20_CONSTEXPR
> >      typename _Distance_traits<_Iterator>::__type
> >      _Safe_iterator<_Iterator, _Sequence, _Category>::
> >      _M_get_distance_to_end() const
> > @@ -82,6 +84,7 @@
> >      }
> >
> >    template<typename _Iterator, typename _Sequence, typename _Category>
> > +    _GLIBCXX20_CONSTEXPR
> >      bool
> >      _Safe_iterator<_Iterator, _Sequence, _Category>::
> >      _M_can_advance(difference_type __n, bool __strict) const
> > @@ -109,6 +112,7 @@
> >
> >    template<typename _Iterator, typename _Sequence, typename _Category>
> >      template<typename _Diff>
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        _Safe_iterator<_Iterator, _Sequence, _Category>::
> >        _M_can_advance(const std::pair<_Diff, _Distance_precision>& __dist,
> > @@ -221,6 +225,7 @@
> >      }
> >
> >    template<typename _Iterator, typename _Sequence>
> > +    _GLIBCXX20_CONSTEXPR
> >      bool
> >      _Safe_iterator<_Iterator, _Sequence, std::random_access_iterator_tag>::
> >      _M_valid_range(const _Safe_iterator& __rhs,
> > diff --git a/libstdc++-v3/include/debug/safe_sequence.h 
> > b/libstdc++-v3/include/debug/safe_sequence.h
> > index 4415f689c9f..49ece94a25a 100644
> > --- a/libstdc++-v3/include/debug/safe_sequence.h
> > +++ b/libstdc++-v3/include/debug/safe_sequence.h
> > @@ -65,6 +65,7 @@ namespace __gnu_debug
> >        _GLIBCXX20_CONSTEXPR
> >        explicit _Equal_to(const _Type& __v) : __value(__v) { }
> >
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        operator()(const _Type& __x) const
> >        { return __value == __x; }
> > @@ -86,6 +87,7 @@ namespace __gnu_debug
> >        _After_nth_from(const difference_type& __n, const _Iterator& __base)
> >        : _M_base(__base), _M_n(__n) { }
> >
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        operator()(const _Iterator& __x) const
> >        { return __x - _M_base >= _M_n; }
> > @@ -111,6 +113,7 @@ namespace __gnu_debug
> >      class _Safe_sequence : public _Safe_sequence_base
> >      {
> >        template<typename _Predicate>
> > +       _GLIBCXX23_CONSTEXPR
> >         void
> >         _M_invalidate_if_impl(_Predicate __pred) const;
> >
> > diff --git a/libstdc++-v3/include/debug/safe_sequence.tcc 
> > b/libstdc++-v3/include/debug/safe_sequence.tcc
> > index f55767258be..1f57514709f 100644
> > --- a/libstdc++-v3/include/debug/safe_sequence.tcc
> > +++ b/libstdc++-v3/include/debug/safe_sequence.tcc
> > @@ -33,6 +33,7 @@
> >  {
> >    template<typename _Sequence>
> >      template<typename _Predicate>
> > +      _GLIBCXX23_CONSTEXPR
> >        void
> >        _Safe_sequence<_Sequence>::
> >        _M_invalidate_if_impl(_Predicate __pred) const
> > diff --git a/libstdc++-v3/include/debug/vector 
> > b/libstdc++-v3/include/debug/vector
> > index 61e5ff78a7a..cb0a48e4886 100644
> > --- a/libstdc++-v3/include/debug/vector
> > +++ b/libstdc++-v3/include/debug/vector
> > @@ -103,6 +103,7 @@
> >
> >        size_type _M_guaranteed_capacity;
> >
> > +      _GLIBCXX20_CONSTEXPR
> >        bool
> >        _M_requires_reallocation(size_type __elements) const 
> > _GLIBCXX_NOEXCEPT
> >        { return __elements > _M_seq().capacity(); }
> > @@ -920,6 +921,7 @@
> >  #endif
> >
> >      private:
> > +      _GLIBCXX20_CONSTEXPR
> >        void
> >        _M_invalidate_after_nth(difference_type __n) _GLIBCXX_NOEXCEPT
> >        {
> > diff --git 
> > a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc
> >  
> > b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc
> > index 2c9abcdbb91..e5e76b0893f 100644
> > --- 
> > a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc
> > +++ 
> > b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc
> > @@ -47,4 +47,4 @@
> >  // { dg-error "PrivateDtor.* is private" "" { target *-*-* } 0 }
> >
> >  // In Debug Mode the "required from here" errors come from <debug/vector>
> > -// { dg-error "required from here" "" { target *-*-* } 182 }
> > +// { dg-error "required from here" "" { target *-*-* } 183 }
> > diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/124312.cc 
> > b/libstdc++-v3/testsuite/23_containers/vector/debug/124312.cc
> > new file mode 100644
> > index 000000000..7c5d8269d
> > --- /dev/null
> > +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/124312.cc
> > @@ -0,0 +1,131 @@
> > +// PR c++/124312: evaluated reflection-vector use.
> > +// { dg-do compile { target c++26 } }
> > +// { dg-additional-options "-freflection -D_GLIBCXX_DEBUG" }
> > +
> > +#include <algorithm>
> > +#include <iterator>
> > +#include <meta>
> > +#include <vector>
> > +
> > +struct sample { int first; int second; int third; };
> > +
> > +consteval std::vector<std::meta::info>
> > +get_members()
> > +{
> > +  return std::meta::nonstatic_data_members_of(
> > +    ^^sample, std::meta::access_context::unprivileged());
> > +}
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  auto it = members.begin();
> > +  return *it++ == ^^sample::first && *it == ^^sample::second
> > +    && *it-- == ^^sample::second && *it == ^^sample::first
> > +    && members.end() - members.begin() == 3 && it[2] == ^^sample::third
> > +    && *(it + 1) == ^^sample::second && *members.rbegin() == 
> > ^^sample::third;
> > +}(), "iterator operations");
> > +
> > +static_assert([] {
> > +  auto members = get_members();
> > +  return std::ranges::find(members, ^^sample::second) == members.begin() + 
> > 1;
> > +}(), "find");
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  std::vector<std::meta::info> reversed(members.rbegin(), members.rend());
> > +  return reversed.size() == 3 && reversed.front() == ^^sample::third
> > +    && reversed.back() == ^^sample::first;
> > +}(), "construction from reverse iterators");
> > +
> > +static_assert([] {
> > +  auto members = get_members();
> > +  std::vector<std::meta::info> moved(
> > +    std::make_move_iterator(members.begin()),
> > +    std::make_move_iterator(members.end()));
> > +  return std::ranges::equal(moved, members);
> > +}(), "construction from move iterators");
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  std::vector<std::meta::info> copy(3);
> > +  std::copy(members.begin(), members.end(), copy.begin());
> > +  return std::equal(members.begin(), members.end(), copy.begin());
> > +}(), "copy");
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  std::vector<std::meta::info> copy(3);
> > +  std::copy_backward(members.begin(), members.end(), copy.end());
> > +  return std::ranges::equal(copy, members);
> > +}(), "copy_backward");
> > +
> > +static_assert([] {
> > +  auto members = get_members();
> > +  std::rotate(members.begin(), members.begin() + 1, members.end());
> > +  return members.front() == ^^sample::second
> > +    && members[1] == ^^sample::third && members.back() == ^^sample::first;
> > +}(), "rotate");
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  std::vector<std::meta::info> reversed;
> > +  std::copy(members.rbegin(), members.rend(), 
> > std::back_inserter(reversed));
> > +  return reversed.size() == 3 && reversed.front() == ^^sample::third
> > +    && reversed[1] == ^^sample::second && reversed.back() == 
> > ^^sample::first;
> > +}(), "copy from reverse iterators to back_inserter");
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  std::vector<std::meta::info> reversed(
> > +    std::make_reverse_iterator(members.data() + members.size()),
> > +    std::make_reverse_iterator(members.data()));
> > +  return reversed.size() == 3 && reversed.front() == ^^sample::third
> > +    && reversed[1] == ^^sample::second && reversed.back() == 
> > ^^sample::first;
> > +}(), "construction from reverse pointer iterators");
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  std::vector<std::meta::info> moved(
> > +    std::make_move_iterator(members.data()),
> > +    std::make_move_iterator(members.data() + members.size()));
> > +  return std::ranges::equal(moved, members);
> > +}(), "construction from move pointer iterators");
> > +
> > +static_assert([] {
> > +  std::vector<std::meta::info> members;
> > +  members.reserve(4);
> > +  return members.empty() && members.capacity() >= 4;
> > +}(), "reserve");
> > +
> > +static_assert([] {
> > +  const auto members = get_members();
> > +  std::vector<std::meta::info> copy;
> > +  std::ranges::copy(members, std::back_inserter(copy));
> > +  return std::ranges::equal(copy, members);
> > +}(), "ranges::copy to back_inserter");
> > +
> > +static_assert([] {
> > +  auto members = get_members();
> > +  members.erase(members.begin());
> > +  return members.size() == 2 && members.front() == ^^sample::second
> > +    && members.back() == ^^sample::third;
> > +}(), "erase one element");
> > +
> > +static_assert([] {
> > +  auto members = get_members();
> > +  members.insert(members.begin(), ^^int);
> > +  return members.size() == 4 && members.front() == (^^int)
> > +    && members[1] == ^^sample::first && members.back() == ^^sample::third;
> > +}(), "insert one element");
> > +
> > +static_assert([] {
> > +  auto members = get_members();
> > +  members.push_back(^^int);
> > +  return members.size() == 4 && members.back() == ^^int;
> > +}(), "push_back");
> > +
> > +static_assert([] {
> > +  auto members = get_members();
> > +  members.pop_back();
> > +  return members.size() == 2 && members.back() == ^^sample::second;
> > +}(), "pop_back");
> > --
> > 2.47.0
> >

Reply via email to