public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Francois Dumont <fdumont@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-9046] libstdc++: [_GLIBCXX_DEBUG] Fix std::__niter_base behavior Date: Sat, 17 Feb 2024 14:12:48 +0000 (GMT) [thread overview] Message-ID: <20240217141248.6941A385DC2B@sourceware.org> (raw) https://gcc.gnu.org/g:9739d7ebf05aefcdd85477900528d8bee69df215 commit r14-9046-g9739d7ebf05aefcdd85477900528d8bee69df215 Author: François Dumont <fdumont@gcc.gnu.org> Date: Wed Feb 14 06:59:12 2024 +0100 libstdc++: [_GLIBCXX_DEBUG] Fix std::__niter_base behavior std::__niter_base is used in _GLIBCXX_DEBUG mode to remove _Safe_iterator<> wrapper on random access iterators. But doing so it should also preserve original behavior to remove __normal_iterator wrapper. libstdc++-v3/ChangeLog: * include/bits/stl_algobase.h (std::__niter_base): Redefine the overload definitions for __gnu_debug::_Safe_iterator. * include/debug/safe_iterator.tcc (std::__niter_base): Adapt declarations. Diff: --- libstdc++-v3/include/bits/stl_algobase.h | 16 +++++++++++++++- libstdc++-v3/include/debug/safe_iterator.tcc | 18 +++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index e7207f672665..0f73da131729 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -317,12 +317,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible<_Iterator>::value) { return __it; } +#if __cplusplus < 201103L template<typename _Ite, typename _Seq> - _GLIBCXX20_CONSTEXPR _Ite __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, std::random_access_iterator_tag>&); + template<typename _Ite, typename _Cont, typename _Seq> + _Ite + __niter_base(const ::__gnu_debug::_Safe_iterator< + ::__gnu_cxx::__normal_iterator<_Ite, _Cont>, _Seq, + std::random_access_iterator_tag>&); +#else + template<typename _Ite, typename _Seq> + _GLIBCXX20_CONSTEXPR + decltype(std::__niter_base(std::declval<_Ite>())) + __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, + std::random_access_iterator_tag>&) + noexcept(std::is_nothrow_copy_constructible<_Ite>::value); +#endif + // Reverse the __niter_base transformation to get a // __normal_iterator back again (this assumes that __normal_iterator // is only used to wrap random access iterators, like pointers). diff --git a/libstdc++-v3/include/debug/safe_iterator.tcc b/libstdc++-v3/include/debug/safe_iterator.tcc index 6eb70cbda049..a8b24233e854 100644 --- a/libstdc++-v3/include/debug/safe_iterator.tcc +++ b/libstdc++-v3/include/debug/safe_iterator.tcc @@ -235,13 +235,29 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if __cplusplus < 201103L template<typename _Ite, typename _Seq> - _GLIBCXX20_CONSTEXPR _Ite __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, std::random_access_iterator_tag>& __it) { return __it.base(); } + template<typename _Ite, typename _Cont, typename _DbgSeq> + _Ite + __niter_base(const ::__gnu_debug::_Safe_iterator< + ::__gnu_cxx::__normal_iterator<_Ite, _Cont>, _DbgSeq, + std::random_access_iterator_tag>& __it) + { return __it.base().base(); } +#else + template<typename _Ite, typename _Seq> + _GLIBCXX20_CONSTEXPR + decltype(std::__niter_base(std::declval<_Ite>())) + __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, + std::random_access_iterator_tag>& __it) + noexcept(std::is_nothrow_copy_constructible<_Ite>::value) + { return std::__niter_base(__it.base()); } +#endif + template<bool _IsMove, typename _Ite, typename _Seq, typename _Cat, typename _OI> _GLIBCXX20_CONSTEXPR
reply other threads:[~2024-02-17 14:12 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240217141248.6941A385DC2B@sourceware.org \ --to=fdumont@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).