diff options
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp')
-rw-r--r-- | libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp index 049ccfe9871..1c25b480858 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp @@ -12,7 +12,7 @@ // template<ForwardIterator Iter> // requires OutputIterator<Iter, Iter::reference> // && EqualityComparable<Iter::value_type> -// Iter +// constexpr Iter // constexpr after C++17 // unique(Iter first, Iter last); #include <algorithm> @@ -22,6 +22,19 @@ #include "test_macros.h" #include "test_iterators.h" +#if TEST_STD_VER > 17 +TEST_CONSTEXPR bool test_constexpr() { + int ia[] = {0, 1, 1, 3, 4}; + const int expected[] = {0, 1, 3, 4}; + const size_t N = 4; + + auto it = std::unique(std::begin(ia), std::end(ia)); + return it == (std::begin(ia) + N) + && std::equal(std::begin(ia), it, std::begin(expected), std::end(expected)) + ; + } +#endif + template <class Iter> void test() @@ -182,4 +195,8 @@ int main() test1<random_access_iterator<Ptr*> >(); test1<Ptr*>(); #endif + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } |