On Fri, 24 Apr 2026 at 09:57, Tomasz Kamiński <[email protected]> wrote:
>
> This resolves 4253. basic_const_iterator should provide iterator_type.
I think this would be more readable as:
This resolves LWG 4253, "basic_const_iterator should provide iterator_type"
which was approved in Kona 2025.
OK with that change, thanks
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/stl_iterator.h (basic_const_iterator::iterator_type):
> Define.
> * testsuite/24_iterators/const_iterator/1.cc: Tests for
> iterator_type.
> ---
> Tested on x86_64-linux. OK for trunk?
>
> libstdc++-v3/include/bits/stl_iterator.h | 3 +++
> libstdc++-v3/testsuite/24_iterators/const_iterator/1.cc | 2 ++
> 2 files changed, 5 insertions(+)
>
> diff --git a/libstdc++-v3/include/bits/stl_iterator.h
> b/libstdc++-v3/include/bits/stl_iterator.h
> index f16f591ad63..6439deb608a 100644
> --- a/libstdc++-v3/include/bits/stl_iterator.h
> +++ b/libstdc++-v3/include/bits/stl_iterator.h
> @@ -2691,6 +2691,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> template<input_iterator _It2> friend class basic_const_iterator;
>
> public:
> + // _GLIBCXX_RESOLVE_LIB_DEFECTS
> + // 4253. basic_const_iterator should provide iterator_type
> + using iterator_type = _It;
> using iterator_concept = decltype(_S_iter_concept());
> using value_type = iter_value_t<_It>;
> using difference_type = iter_difference_t<_It>;
> diff --git a/libstdc++-v3/testsuite/24_iterators/const_iterator/1.cc
> b/libstdc++-v3/testsuite/24_iterators/const_iterator/1.cc
> index f2bcad4f09c..7f791ddbef9 100644
> --- a/libstdc++-v3/testsuite/24_iterators/const_iterator/1.cc
> +++ b/libstdc++-v3/testsuite/24_iterators/const_iterator/1.cc
> @@ -29,6 +29,7 @@ test01()
> else
> {
> using Wrapped = std::basic_const_iterator<Iter>;
> + static_assert( std::same_as<typename Wrapped::iterator_type, Iter> );
>
> static_assert( std::same_as<std::const_iterator<Iter>, Wrapped> );
> static_assert( std::same_as<std::const_sentinel<Iter>, Wrapped> );
> @@ -64,6 +65,7 @@ test02()
> {
> static_assert( !ranges::constant_range<Range> );
> using Wrapped = std::basic_const_iterator<ranges::iterator_t<Range>>;
> + static_assert( std::same_as<typename Wrapped::iterator_type,
> ranges::iterator_t<Range>> );
>
> if constexpr (Constable)
> {
> --
> 2.53.0
>