summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2018-01-16 15:48:27 +0000
committerMarshall Clow <mclow.lists@gmail.com>2018-01-16 15:48:27 +0000
commit12f0a77902fb71b7a7095551450f8bd494aaff68 (patch)
tree2949a47fa956cdc1148c5ff684d5bafb94dc769f /libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
parente1d2d22d2a1c329d269b13e2d43c97fd5e8838aa (diff)
downloadbcm5719-llvm-12f0a77902fb71b7a7095551450f8bd494aaff68.tar.gz
bcm5719-llvm-12f0a77902fb71b7a7095551450f8bd494aaff68.zip
More constexpr algorithms from P0202. search/search_n
llvm-svn: 322566
Diffstat (limited to 'libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp')
-rw-r--r--libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
index 192da03d67b..21a17116fc8 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
@@ -11,14 +11,28 @@
// template<ForwardIterator Iter1, ForwardIterator Iter2>
// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
-// Iter1
+// constexpr Iter1 // constexpr after C++17
// search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool eq(int a, int b) { return a == b; }
+
+TEST_CONSTEXPR bool test_constexpr() {
+ int ia[] = {0, 1, 2, 3};
+ int ib[] = {0, 1, 5, 3};
+ int ic[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+ return (std::search(std::begin(ic), std::end(ic), std::begin(ia), std::end(ia), eq) == ic+3)
+ && (std::search(std::begin(ic), std::end(ic), std::begin(ib), std::end(ib), eq) == std::end(ic))
+ ;
+ }
+#endif
+
struct count_equal
{
static unsigned count;
@@ -108,4 +122,8 @@ int main()
test<random_access_iterator<const int*>, forward_iterator<const int*> >();
test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
OpenPOWER on IntegriCloud