This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] C++14: N3671 Making non-modifying sequence operations more robust
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 11 Jun 2013 00:09:59 +0100
- Subject: Re: [patch] C++14: N3671 Making non-modifying sequence operations more robust
- References: <CAH6eHdQWhZjPJczqLT+jYs16RuokiqezVJcia_5up6e1KbevBg at mail dot gmail dot com> <51B6342A dot 5090407 at gmail dot com>
On 10 June 2013 21:16, François Dumont wrote:
> @@ -810,6 +823,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> return !__builtin_memcmp(__first1, __first2, sizeof(_Tp)
> * (__last1 - __first1));
> }
> +
> +#if __cplusplus > 201103L
> + template<typename _Tp>
> + static bool
> + equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2,
> + const _Tp* __last2)
> + {
> + return !__builtin_memcmp(__first1, __first2, sizeof(_Tp)
> + * (__last1 - __first1));
> + }
> +#endif
> };
>
> I think there is a problem here. I had a closer look because __last2 is not
> consider in the version taking pointers.
Oops, yes, I copied the existing code then didn't update it.
> We could start reading after
> __last2, something Valgrin could catch perhaps. A consistent version would
> be:
>
> +#if __cplusplus > 201103L
> + template<typename _Tp>
> + static bool
> + equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2,
> + const _Tp* __last2)
> + {
> + if (__builtin_memcmp(__first1, __first2, sizeof(_Tp)
> + * std::min(__last1 - __first1, __last2 -
> __first2))
> + return false;
> + return true;
> + }
> +#endif
>
> But I am not sure it is the intended behavior because I can't see where
> those equal overloads are used. It looks like __equal2 has been implemented
> and used instead. Maybe some dead code to clean, no ?
It should be used, I'll check it.