forked from OSchip/llvm-project
partition_point gets the P0202 treatment
llvm-svn: 322493
This commit is contained in:
parent
706ffef713
commit
674f9128b7
|
@ -321,7 +321,7 @@ template <class ForwardIterator, class Predicate>
|
||||||
stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
|
stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
|
||||||
|
|
||||||
template<class ForwardIterator, class Predicate>
|
template<class ForwardIterator, class Predicate>
|
||||||
ForwardIterator
|
ForwardIterator // constexpr in C++20
|
||||||
partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
|
partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
|
||||||
|
|
||||||
template <class ForwardIterator>
|
template <class ForwardIterator>
|
||||||
|
@ -3328,7 +3328,7 @@ partition_copy(_InputIterator __first, _InputIterator __last,
|
||||||
// partition_point
|
// partition_point
|
||||||
|
|
||||||
template<class _ForwardIterator, class _Predicate>
|
template<class _ForwardIterator, class _Predicate>
|
||||||
_ForwardIterator
|
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
|
||||||
partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
|
partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
|
||||||
{
|
{
|
||||||
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
|
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
|
||||||
|
|
|
@ -10,19 +10,32 @@
|
||||||
// <algorithm>
|
// <algorithm>
|
||||||
|
|
||||||
// template<class ForwardIterator, class Predicate>
|
// template<class ForwardIterator, class Predicate>
|
||||||
// ForwardIterator
|
// constpexr ForwardIterator // constexpr after C++17
|
||||||
// partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
|
// partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
|
|
||||||
struct is_odd
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -73,4 +86,8 @@ int main()
|
||||||
forward_iterator<const int*>(std::begin(ia)),
|
forward_iterator<const int*>(std::begin(ia)),
|
||||||
is_odd()) == forward_iterator<const int*>(ia));
|
is_odd()) == forward_iterator<const int*>(ia));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
static_assert(test_constexpr());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// <algorithm>
|
// <algorithm>
|
||||||
|
|
||||||
// template <class InputIterator, class Predicate>
|
// template <class InputIterator, class Predicate>
|
||||||
// bool
|
// constpexr bool // constexpr after C++17
|
||||||
// all_of(InputIterator first, InputIterator last, Predicate pred);
|
// all_of(InputIterator first, InputIterator last, Predicate pred);
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// <algorithm>
|
// <algorithm>
|
||||||
|
|
||||||
// template <class InputIterator, class Predicate>
|
// template <class InputIterator, class Predicate>
|
||||||
// bool
|
// constpexr bool // constexpr after C++17
|
||||||
// any_of(InputIterator first, InputIterator last, Predicate pred);
|
// any_of(InputIterator first, InputIterator last, Predicate pred);
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
Loading…
Reference in New Issue