libstdc++: Define new C++17 std::search overload for Parallel Mode [PR 94971]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 4 Nov 2020 13:36:32 +0000 (13:36 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 4 Nov 2020 13:36:32 +0000 (13:36 +0000)
libstdc++-v3/ChangeLog:

PR libstdc++/94971
* include/bits/stl_algo.h (search(FIter, FIter, const Searcher):
Adjust #if condition.
* include/parallel/algo.h (search(FIter, FIter, const Searcher&):
Define new overload for C++17.

libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/parallel/algo.h

index 621c6331422e0cf23031b3492fca843da486b3fc..6efc99035b7d96a23b5b2fbdf73c6ea52f6afe9c 100644 (file)
@@ -4243,7 +4243,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
                __gnu_cxx::__ops::__iter_comp_val(__binary_pred, __val));
     }
 
-#if __cplusplus > 201402L
+#if __cplusplus >= 201703L
   /** @brief Search a sequence using a Searcher object.
    *
    *  @param  __first        A forward iterator.
index cec6fd003c38dfb28d3da86e4e7b34d03df7e134..4b6dcc8411918d75a8d628af71e27d4d9303eb50 100644 (file)
@@ -1049,6 +1049,21 @@ namespace __parallel
                             std::__iterator_category(__begin2));
     }
 
+#if __cplusplus >= 201703L
+  /** @brief Search a sequence using a Searcher object.
+   *
+   *  @param  __first        A forward iterator.
+   *  @param  __last         A forward iterator.
+   *  @param  __searcher     A callable object.
+   *  @return @p __searcher(__first,__last).first
+  */
+  template<typename _ForwardIterator, typename _Searcher>
+    inline _ForwardIterator
+    search(_ForwardIterator __first, _ForwardIterator __last,
+          const _Searcher& __searcher)
+    { return __searcher(__first, __last).first; }
+#endif
+
   // Sequential fallback
   template<typename _FIterator, typename _Integer, typename _Tp>
     inline _FIterator