mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 12:02:36 +08:00
partition_point gets the P0202 treatment
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322493 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user