This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Debug unordered containers code cleanup
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 23 Oct 2018 10:52:54 +0100
- Subject: Re: Debug unordered containers code cleanup
- References: <044a9636-a4df-bd60-f0f1-704c770785fe@gmail.com>
On 22/10/18 22:45 +0200, François Dumont wrote:
I plan to commit the attached patch this week if not told otherwise.
Looks good.
This is to generalize usage of C++11 direct initialization in
unordered containers.
It also avoids a number of safe iterator instantiations.
Would the following patch also make sense?
--- a/libstdc++-v3/include/debug/safe_unordered_container.h
+++ b/libstdc++-v3/include/debug/safe_unordered_container.h
@@ -66,18 +66,18 @@ namespace __gnu_debug
void
_M_invalidate_locals()
{
- auto __local_end = _M_cont()._M_base().end(0);
+ auto __local_end = _M_cont()._M_base().cend(0);
this->_M_invalidate_local_if(
- [__local_end](__decltype(_M_cont()._M_base().cend(0)) __it)
+ [__local_end](__decltype(__local_end) __it)
{ return __it != __local_end; });
}
void
_M_invalidate_all()
{
- auto __end = _M_cont()._M_base().end();
+ auto __end = _M_cont()._M_base().cend();
this->_M_invalidate_if(
- [__end](__decltype(_M_cont()._M_base().cend()) __it)
+ [__end](__decltype(__end) __it)
{ return __it != __end; });
_M_invalidate_locals();
}
@@ -92,7 +92,7 @@ namespace __gnu_debug
/** Invalidates all local iterators @c x that reference this container,
are not singular, and for which @c __pred(x) returns @c
- true. @c __pred will be invoked with the normal ilocal iterators
+ true. @c __pred will be invoked with the normal local iterators
nested in the safe ones. */
template<typename _Predicate>
void