public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Debug iterators operator->
@ 2015-11-18 21:33 François Dumont
  0 siblings, 0 replies; only message in thread
From: François Dumont @ 2015-11-18 21:33 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

Hi

    I always wanted to fix those operators implementation so that it
just use underlying iterator -> operator like for the other operators.
And I also notice the @todo on it today so maybe it is still time to fix
those.

    * include/debug/safe_iterator.h
    (_Safe_iterator<>::operator->()): Implement using underlying iterator
    same operator.
    * include/debug/safe_local_iterator.h
    (_Safe_local_iterator<>::operator->()): Likewise.


Tested under Linux x86_64 debug mode of course.

François


[-- Attachment #2: debug_ite.patch --]
[-- Type: text/x-patch, Size: 1624 bytes --]

diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h
index a8bee21..ed08d19 100644
--- a/libstdc++-v3/include/debug/safe_iterator.h
+++ b/libstdc++-v3/include/debug/safe_iterator.h
@@ -274,7 +274,6 @@ namespace __gnu_debug
       /**
        *  @brief Iterator dereference.
        *  @pre iterator is dereferenceable
-       *  @todo Make this correct w.r.t. iterators that return proxies
        */
       pointer
       operator->() const _GLIBCXX_NOEXCEPT
@@ -282,7 +281,7 @@ namespace __gnu_debug
 	_GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(),
 			      _M_message(__msg_bad_deref)
 			      ._M_iterator(*this, "this"));
-	return std::__addressof(*base());
+	return base().operator->();
       }
 
       // ------ Input iterator requirements ------
diff --git a/libstdc++-v3/include/debug/safe_local_iterator.h b/libstdc++-v3/include/debug/safe_local_iterator.h
index 350a1d2..f60b6e9 100644
--- a/libstdc++-v3/include/debug/safe_local_iterator.h
+++ b/libstdc++-v3/include/debug/safe_local_iterator.h
@@ -236,7 +236,6 @@ namespace __gnu_debug
       /**
        *  @brief Iterator dereference.
        *  @pre iterator is dereferenceable
-       *  @todo Make this correct w.r.t. iterators that return proxies
        */
       pointer
       operator->() const
@@ -244,7 +243,7 @@ namespace __gnu_debug
 	_GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(),
 			      _M_message(__msg_bad_deref)
 			      ._M_iterator(*this, "this"));
-	return std::__addressof(*base());
+	return base().operator->();
       }
 
       // ------ Input iterator requirements ------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-18 21:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-18 21:33 Debug iterators operator-> François Dumont

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).