[libcxx] r322493 - partition_point gets the P0202 treatment
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 15 09:53:34 PST 2018
Author: marshall
Date: Mon Jan 15 09:53:34 2018
New Revision: 322493
URL: http://llvm.org/viewvc/llvm-project?rev=322493&view=rev
Log:
partition_point gets the P0202 treatment
Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
Modified: libcxx/trunk/include/algorithm
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=322493&r1=322492&r2=322493&view=diff
==============================================================================
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Jan 15 09:53:34 2018
@@ -321,7 +321,7 @@ template <class ForwardIterator, class P
stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
template<class ForwardIterator, class Predicate>
- ForwardIterator
+ ForwardIterator // constexpr in C++20
partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
template <class ForwardIterator>
@@ -3328,7 +3328,7 @@ partition_copy(_InputIterator __first, _
// partition_point
template<class _ForwardIterator, class _Predicate>
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp?rev=322493&r1=322492&r2=322493&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp Mon Jan 15 09:53:34 2018
@@ -10,19 +10,32 @@
// <algorithm>
// template<class ForwardIterator, class Predicate>
-// ForwardIterator
+// constpexr ForwardIterator // constexpr after C++17
// partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
struct is_odd
{
- bool operator()(const int& i) const {return i & 1;}
+ TEST_CONSTEXPR bool operator()(const int& i) const {return i & 1;}
};
+
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR int test_constexpr() {
+ int ia[] = {1, 3, 5, 2, 4, 6};
+ int ib[] = {1, 2, 3, 4, 5, 6};
+ return (std::partition_point(std::begin(ia), std::end(ia), is_odd()) == ia+3)
+ && (std::partition_point(std::begin(ib), std::end(ib), is_odd()) == ib+1)
+ ;
+ }
+#endif
+
+
int main()
{
{
@@ -73,4 +86,8 @@ int main()
forward_iterator<const int*>(std::begin(ia)),
is_odd()) == forward_iterator<const int*>(ia));
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
Modified: libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp?rev=322493&r1=322492&r2=322493&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp Mon Jan 15 09:53:34 2018
@@ -10,7 +10,7 @@
// <algorithm>
// template <class InputIterator, class Predicate>
-// bool
+// constpexr bool // constexpr after C++17
// all_of(InputIterator first, InputIterator last, Predicate pred);
#include <algorithm>
Modified: libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp?rev=322493&r1=322492&r2=322493&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp Mon Jan 15 09:53:34 2018
@@ -10,7 +10,7 @@
// <algorithm>
// template <class InputIterator, class Predicate>
-// bool
+// constpexr bool // constexpr after C++17
// any_of(InputIterator first, InputIterator last, Predicate pred);
#include <algorithm>
More information about the cfe-commits
mailing list