Debug unordered containers code cleanup
François Dumont
frs.dumont@gmail.com
Tue Oct 23 20:35:00 GMT 2018
On 10/23/2018 11:52 AM, Jonathan Wakely wrote:
> 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
>
>
>
Yes, looks like a nice cleanup too.
I'll integrate it in mine and commit all the changes once tests are
completed.
François
More information about the Libstdc++
mailing list