mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
More constexpr algorithms from P0202. any_of/all_of/none_of.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,16 +16,27 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct test1
|
||||
{
|
||||
bool operator()(const int& i) const
|
||||
TEST_CONSTEXPR bool operator()(const int& i) const
|
||||
{
|
||||
return i % 2 == 0;
|
||||
}
|
||||
};
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
TEST_CONSTEXPR int test_constexpr() {
|
||||
int ia[] = {1, 3, 6, 7};
|
||||
int ib[] = {1, 3, 5, 7};
|
||||
return !std::none_of(std::begin(ia), std::end(ia), test1())
|
||||
&& std::none_of(std::begin(ib), std::end(ib), test1())
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -52,4 +63,8 @@ int main()
|
||||
assert(std::none_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == true);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
static_assert(test_constexpr());
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user