summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.nonmodifying
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2018-01-15 16:16:32 +0000
committerMarshall Clow <mclow.lists@gmail.com>2018-01-15 16:16:32 +0000
commit49c7643c39b0adb6ec88528ad7da01dd82deb84b (patch)
tree297a49e441a71c80d48a14088679bb3e14f459c2 /libcxx/test/std/algorithms/alg.nonmodifying
parent776a81a483da73b52f8d73ce441b0f03dbf5411b (diff)
downloadbcm5719-llvm-49c7643c39b0adb6ec88528ad7da01dd82deb84b.tar.gz
bcm5719-llvm-49c7643c39b0adb6ec88528ad7da01dd82deb84b.zip
First part of P0202: Adding constexpr modifiers to functions in <algorithm> and <utility>. This commit is all the is_XXX algorithms.
llvm-svn: 322489
Diffstat (limited to 'libcxx/test/std/algorithms/alg.nonmodifying')
-rw-r--r--libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp21
-rw-r--r--libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp21
2 files changed, 40 insertions, 2 deletions
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
index e3f7c3cd87d..cde76d5ca06 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
@@ -10,7 +10,7 @@
// <algorithm>
// template<class ForwardIterator1, class ForwardIterator2>
-// bool
+// constexpr bool // constexpr after C++17
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
// ForwardIterator2 first2);
@@ -21,6 +21,21 @@
#include "test_macros.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 0, 0};
+ int ib[] = {1, 1, 0};
+ int ic[] = {1, 0, 1};
+ int id[] = {1};
+ return !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib))
+ && !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib))
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic))
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic), std::end(ic))
+ && !std::is_permutation(std::begin(ic), std::end(ic), std::begin(id), std::end(id))
+ ;
+ }
+#endif
+
int main()
{
{
@@ -600,4 +615,8 @@ int main()
forward_iterator<const int*>(ib + sa)) == false);
#endif
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
index 6e9cdaabd30..13129289629 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
@@ -10,7 +10,7 @@
// <algorithm>
// template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
-// bool
+// constexpr bool // constexpr after C++17
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
// ForwardIterator2 first2, BinaryPredicate pred);
@@ -28,6 +28,21 @@ bool counting_equals ( const T &a, const T &b ) {
return a == b;
}
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {0, 0, 0};
+ int ib[] = {1, 1, 0};
+ int ic[] = {1, 0, 1};
+ int id[] = {1};
+ std::equal_to<int> c;
+ return !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib) , c)
+ && !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib), c)
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic) , c)
+ && std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic), std::end(ic), c)
+ && !std::is_permutation(std::begin(ic), std::end(ic), std::begin(id), std::end(id), c)
+ ;
+ }
+#endif
int main()
{
@@ -723,4 +738,8 @@ int main()
std::equal_to<const int>()) == false);
#endif
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
OpenPOWER on IntegriCloud