[PATCH] libstdc++: Define flat_set::operator== in terms of ==
Tomasz Kaminski
tkaminsk@redhat.com
Thu May 29 20:10:47 GMT 2025
On Thu, May 29, 2025 at 7:14 PM Patrick Palka <ppalka@redhat.com> wrote:
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk/15?
>
> -- >8 --
>
> ... for consistency with the other standard container adaptors
> (stack, queue, etc).
>
> libstdc++-v3/ChangeLog:
>
> * include/std/flat_set (_Flat_set_impl::operator==):
> Define in terms of ==, not std::equal.
> ---
>
LGTM. I think this at the end is the best choice, as containers may have
more information than iterators,
to perform comparison quicker.
> libstdc++-v3/include/std/flat_set | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/std/flat_set
> b/libstdc++-v3/include/std/flat_set
> index c48340d79809..3da8882d154e 100644
> --- a/libstdc++-v3/include/std/flat_set
> +++ b/libstdc++-v3/include/std/flat_set
> @@ -728,7 +728,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> [[nodiscard]]
> friend bool
> operator==(const _Derived& __x, const _Derived& __y)
> - { return std::equal(__x.begin(), __x.end(), __y.begin(),
> __y.end()); }
> + { return __x._M_cont == __y._M_cont; }
>
> template<typename _Up = value_type>
> [[nodiscard]]
> --
> 2.50.0.rc0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20250529/4f28f24c/attachment-0001.htm>
More information about the Libstdc++
mailing list