]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add nodiscard to std::find
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Oct 2024 20:18:14 +0000 (21:18 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 18 Oct 2024 13:49:34 +0000 (14:49 +0100)
I missed this one out in r14-9478-gdf483ebd24689a but I don't think that
was intentional. I see no reason std::find shouldn't be [[nodiscard]].

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h (find): Add nodiscard.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
libstdc++-v3/include/bits/stl_algo.h

index 489ce7e14d24f8b10ef6c1b3d43da42bd0d0b9f8..780bd8e5e8261f6719c67d4f0925bea358e5b634 100644 (file)
@@ -3820,7 +3820,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
    *  such that @c *i == @p __val, or @p __last if no such iterator exists.
   */
   template<typename _InputIterator, typename _Tp>
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
     inline _InputIterator
     find(_InputIterator __first, _InputIterator __last, const _Tp& __val)
     {