[libcxx] r323137 - Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n. These will be enabled when that part of P0202 is implemented. NFC at this time.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 10:38:18 PST 2018
Author: marshall
Date: Mon Jan 22 10:38:18 2018
New Revision: 323137
URL: http://llvm.org/viewvc/llvm-project?rev=323137&view=rev
Log:
Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n. These will be enabled when that part of P0202 is implemented. NFC at this time.
Modified:
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp?rev=323137&r1=323136&r2=323137&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp Mon Jan 22 10:38:18 2018
@@ -10,14 +10,27 @@
// <algorithm>
// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
-// OutIter
+// constexpr OutIter // constexpr after C++17
// copy(InIter first, InIter last, OutIter result);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+// #if TEST_STD_VER > 17
+// TEST_CONSTEXPR bool test_constexpr() {
+// int ia[] = {1, 2, 3, 4, 5};
+// int ic[] = {6, 6, 6, 6, 6, 6, 6};
+//
+// auto p = std::copy(std::begin(ia), std::end(ia), std::begin(ic));
+// return std::equal(std::begin(ia), std::end(ia), std::begin(ic), p)
+// && std::all_of(p, std::end(ic), [](int a){return a == 6;})
+// ;
+// }
+// #endif
+
template <class InIter, class OutIter>
void
test()
@@ -70,4 +83,8 @@ int main()
test<const int*, bidirectional_iterator<int*> >();
test<const int*, random_access_iterator<int*> >();
test<const int*, int*>();
+
+// #if TEST_STD_VER > 17
+// static_assert(test_constexpr());
+// #endif
}
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp?rev=323137&r1=323136&r2=323137&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp Mon Jan 22 10:38:18 2018
@@ -11,13 +11,28 @@
// template<BidirectionalIterator InIter, BidirectionalIterator OutIter>
// requires OutputIterator<OutIter, InIter::reference>
-// OutIter
+// constexpr OutIter // constexpr after C++17
// copy_backward(InIter first, InIter last, OutIter result);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+#include "user_defined_integral.hpp"
+
+// #if TEST_STD_VER > 17
+// TEST_CONSTEXPR bool test_constexpr() {
+// int ia[] = {1, 2, 3, 4, 5};
+// int ic[] = {6, 6, 6, 6, 6, 6, 6};
+//
+// size_t N = std::size(ia);
+// auto p = std::copy_backward(std::begin(ia), std::end(ia), std::begin(ic) + N);
+// return std::equal(std::begin(ic), p, std::begin(ia))
+// && std::all_of(p, std::end(ic), [](int a){return a == 6;})
+// ;
+// }
+// #endif
template <class InIter, class OutIter>
void
@@ -48,4 +63,8 @@ int main()
test<const int*, bidirectional_iterator<int*> >();
test<const int*, random_access_iterator<int*> >();
test<const int*, int*>();
+
+// #if TEST_STD_VER > 17
+// static_assert(test_constexpr());
+// #endif
}
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp?rev=323137&r1=323136&r2=323137&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp Mon Jan 22 10:38:18 2018
@@ -12,14 +12,27 @@
// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter,
// Predicate<auto, InIter::value_type> Pred>
// requires CopyConstructible<Pred>
-// OutIter
+// constexpr OutIter // constexpr after C++17
// copy_if(InIter first, InIter last, OutIter result, Pred pred);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+// #if TEST_STD_VER > 17
+// TEST_CONSTEXPR bool test_constexpr() {
+// int ia[] = {2, 4, 6, 8, 6};
+// int ic[] = {0, 0, 0, 0, 0, 0};
+//
+// auto p = std::copy_if(std::begin(ia), std::end(ia), std::begin(ic), is6);
+// return std::all_of(std::begin(ic), p, [](int a){return a == 6;})
+// && std::all_of(p, std::end(ic), [](int a){return a == 0;})
+// ;
+// }
+// #endif
+
struct Pred
{
bool operator()(int i) {return i % 3 == 0;}
@@ -77,4 +90,8 @@ int main()
test<const int*, bidirectional_iterator<int*> >();
test<const int*, random_access_iterator<int*> >();
test<const int*, int*>();
+
+// #if TEST_STD_VER > 17
+// static_assert(test_constexpr());
+// #endif
}
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp?rev=323137&r1=323136&r2=323137&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp Mon Jan 22 10:38:18 2018
@@ -10,15 +10,28 @@
// <algorithm>
// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
-// OutIter
+// constexpr OutIter // constexpr after C++17
// copy_n(InIter first, InIter::difference_type n, OutIter result);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
#include "user_defined_integral.hpp"
+// #if TEST_STD_VER > 17
+// TEST_CONSTEXPR bool test_constexpr() {
+// int ia[] = {1, 2, 3, 4, 5};
+// int ic[] = {6, 6, 6, 6, 6, 6, 6};
+//
+// auto p = std::copy_n(std::begin(ia), 4, std::begin(ic));
+// return std::equal(std::begin(ic), p, std::begin(ia))
+// && std::all_of(p, std::end(ic), [](int a){return a == 6;})
+// ;
+// }
+// #endif
+
typedef UserDefinedIntegral<unsigned> UDI;
template <class InIter, class OutIter>
@@ -73,4 +86,8 @@ int main()
test<const int*, bidirectional_iterator<int*> >();
test<const int*, random_access_iterator<int*> >();
test<const int*, int*>();
+
+// #if TEST_STD_VER > 17
+// static_assert(test_constexpr());
+// #endif
}
More information about the cfe-commits
mailing list