aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-10-17 21:02:03 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2024-10-18 14:49:34 +0100
commit4020ee77186d1544e8565ae5786af99b8e56543a (patch)
tree0a179d781dac3ff835f6fcdc95196084dca85349 /gcc
parent3abe751ea86e3472fa2c97bf2014f9f93f569019 (diff)
downloadgcc-4020ee77186d1544e8565ae5786af99b8e56543a.zip
gcc-4020ee77186d1544e8565ae5786af99b8e56543a.tar.gz
gcc-4020ee77186d1544e8565ae5786af99b8e56543a.tar.bz2
libstdc++: Make __normal_iterator constexpr, always_inline, nodiscard
The __gnu_cxx::__normal_iterator type we use for std::vector::iterator is not specified by the standard, it's an implementation detail. This means it's not constrained by the rule that forbids strengthening constexpr. We can make it meet the constexpr iterator requirements for older standards, not only when it's required to be for C++20. For the non-const member functions they can't be constexpr in C++11, so use _GLIBCXX14_CONSTEXPR for those. For all constructors, const members and non-member operator overloads, use _GLIBCXX_CONSTEXPR or just constexpr. We can also liberally add [[nodiscard]] and [[gnu::always_inline]] attributes to those functions. Also change some internal helpers for std::move_iterator which can be unconditionally constexpr and marked nodiscard. libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (__normal_iterator): Make all members and overloaded operators constexpr before C++20, and add always_inline attribute (__to_address): Add nodiscard and always_inline attributes. (__make_move_if_noexcept_iterator): Add nodiscard and make unconditionally constexpr. (__niter_base(__normal_iterator), __niter_base(Iter)): Add nodiscard and always_inline attributes. (__niter_base(reverse_iterator), __niter_base(move_iterator)) (__miter_base): Add inline. (__niter_wrap(From, To)): Add nodiscard attribute. (__niter_wrap(const Iter&, Iter)): Add nodiscard and always_inline attributes. Reviewed-by: Patrick Palka <ppalka@redhat.com>
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions