summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2018-01-22 21:43:04 +0000
committerMarshall Clow <mclow.lists@gmail.com>2018-01-22 21:43:04 +0000
commite8ea8296fccc6d9345817ece7d2f4ea3b35a55e1 (patch)
tree3f66bb53ae99e2106d2b00ec787616f85ed47fb0 /libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
parentd2a9592526147bb96103fca21912e0ac40537965 (diff)
downloadbcm5719-llvm-e8ea8296fccc6d9345817ece7d2f4ea3b35a55e1.tar.gz
bcm5719-llvm-e8ea8296fccc6d9345817ece7d2f4ea3b35a55e1.zip
Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy
llvm-svn: 323152
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp')
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
index a77a9eddb19..557984f3900 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
@@ -12,7 +12,7 @@
// template<ForwardIterator Iter, class T>
// requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
// && HasEqualTo<Iter::value_type, T>
-// Iter
+// constexpr Iter // constexpr after C++17
// remove(Iter first, Iter last, const T& value);
#include <algorithm>
@@ -22,6 +22,18 @@
#include "test_macros.h"
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+ int ia[] = {1, 3, 5, 2, 5, 6};
+
+ auto it = std::remove(std::begin(ia), std::end(ia), 5);
+
+ return (std::begin(ia) + std::size(ia) - 2) == it // we removed two elements
+ && std::none_of(std::begin(ia), it, [](int a) {return a == 5; })
+ ;
+ }
+#endif
+
template <class Iter>
void
test()
@@ -75,4 +87,8 @@ int main()
test1<random_access_iterator<std::unique_ptr<int>*> >();
test1<std::unique_ptr<int>*>();
#endif // TEST_STD_VER >= 11
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
OpenPOWER on IntegriCloud