mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00
First part of P0202: Adding constexpr modifiers to functions in <algorithm> and <utility>. This commit is all the is_XXX algorithms.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322489 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
// <algorithm>
|
||||
|
||||
// template<class ForwardIterator1, class ForwardIterator2>
|
||||
// bool
|
||||
// constexpr bool // constexpr after C++17
|
||||
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
// ForwardIterator2 first2);
|
||||
|
||||
@@ -21,6 +21,21 @@
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
TEST_CONSTEXPR int test_constexpr() {
|
||||
int ia[] = {0, 0, 0};
|
||||
int ib[] = {1, 1, 0};
|
||||
int ic[] = {1, 0, 1};
|
||||
int id[] = {1};
|
||||
return !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib))
|
||||
&& !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib))
|
||||
&& std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic))
|
||||
&& std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic), std::end(ic))
|
||||
&& !std::is_permutation(std::begin(ic), std::end(ic), std::begin(id), std::end(id))
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -600,4 +615,8 @@ int main()
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
static_assert(test_constexpr());
|
||||
#endif
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@
|
||||
// <algorithm>
|
||||
|
||||
// template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
|
||||
// bool
|
||||
// constexpr bool // constexpr after C++17
|
||||
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
// ForwardIterator2 first2, BinaryPredicate pred);
|
||||
|
||||
@@ -28,6 +28,21 @@ bool counting_equals ( const T &a, const T &b ) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
TEST_CONSTEXPR int test_constexpr() {
|
||||
int ia[] = {0, 0, 0};
|
||||
int ib[] = {1, 1, 0};
|
||||
int ic[] = {1, 0, 1};
|
||||
int id[] = {1};
|
||||
std::equal_to<int> c;
|
||||
return !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib) , c)
|
||||
&& !std::is_permutation(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib), c)
|
||||
&& std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic) , c)
|
||||
&& std::is_permutation(std::begin(ib), std::end(ib), std::begin(ic), std::end(ic), c)
|
||||
&& !std::is_permutation(std::begin(ic), std::end(ic), std::begin(id), std::end(id), c)
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -723,4 +738,8 @@ int main()
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
static_assert(test_constexpr());
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user