Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter>
|
||||
// requires EqualityComparable<Iter::value_type>
|
||||
// Iter
|
||||
// adjacent_find(Iter first, Iter last);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::adjacent_find(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa)) ==
|
||||
forward_iterator<const int*>(ia+2));
|
||||
assert(std::adjacent_find(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia)) ==
|
||||
forward_iterator<const int*>(ia));
|
||||
assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
|
||||
forward_iterator<const int*>(ia + sa)) ==
|
||||
forward_iterator<const int*>(ia+sa));
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// Iter
|
||||
// adjacent_find(Iter first, Iter last, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::adjacent_find(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
std::equal_to<int>()) ==
|
||||
forward_iterator<const int*>(ia+2));
|
||||
assert(std::adjacent_find(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia),
|
||||
std::equal_to<int>()) ==
|
||||
forward_iterator<const int*>(ia));
|
||||
assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
std::equal_to<int>()) ==
|
||||
forward_iterator<const int*>(ia+sa));
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template <class InputIterator, class Predicate>
|
||||
// bool
|
||||
// all_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct test1
|
||||
{
|
||||
bool operator()(const int& i) const
|
||||
{
|
||||
return i % 2 == 0;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int ia[] = {2, 4, 6, 8};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::all_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == true);
|
||||
assert(std::all_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == true);
|
||||
}
|
||||
{
|
||||
const int ia[] = {2, 4, 5, 8};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::all_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == false);
|
||||
assert(std::all_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == true);
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template <class InputIterator, class Predicate>
|
||||
// bool
|
||||
// any_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct test1
|
||||
{
|
||||
bool operator()(const int& i) const
|
||||
{
|
||||
return i % 2 == 0;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int ia[] = {2, 4, 6, 8};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::any_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == true);
|
||||
assert(std::any_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == false);
|
||||
}
|
||||
{
|
||||
const int ia[] = {2, 4, 5, 8};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::any_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == true);
|
||||
assert(std::any_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == false);
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 3, 5, 7};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::any_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == false);
|
||||
assert(std::any_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter, class T>
|
||||
// requires HasEqualTo<Iter::value_type, T>
|
||||
// Iter::difference_type
|
||||
// count(Iter first, Iter last, const T& value);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::count(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), 2) == 3);
|
||||
assert(std::count(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), 7) == 0);
|
||||
assert(std::count(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), 2) == 0);
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// Iter::difference_type
|
||||
// count_if(Iter first, Iter last, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::count_if(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
std::bind2nd(std::equal_to<int>(),2)) == 3);
|
||||
assert(std::count_if(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
std::bind2nd(std::equal_to<int>(),7)) == 0);
|
||||
assert(std::count_if(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia),
|
||||
std::bind2nd(std::equal_to<int>(),2)) == 0);
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter1, InputIterator Iter2>
|
||||
// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
|
||||
// bool
|
||||
// equal(Iter1 first1, Iter1 last1, Iter2 first2);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned s = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[s] = {0, 1, 2, 5, 4, 5};
|
||||
assert(std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ia)));
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s)));
|
||||
assert(std::equal(random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s),
|
||||
random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s)));
|
||||
#endif
|
||||
assert(!std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ib)));
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(!std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ib),
|
||||
input_iterator<const int*>(ib+s)));
|
||||
assert(!std::equal(random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s),
|
||||
random_access_iterator<const int*>(ib),
|
||||
random_access_iterator<const int*>(ib+s)));
|
||||
assert(!std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s-1)));
|
||||
assert(!std::equal(random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s),
|
||||
random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s-1)));
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter1, InputIterator Iter2,
|
||||
// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// bool
|
||||
// equal(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int comparison_count = 0;
|
||||
template <typename T>
|
||||
bool counting_equals ( const T &a, const T &b ) {
|
||||
++comparison_count;
|
||||
return a == b;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned s = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[s] = {0, 1, 2, 5, 4, 5};
|
||||
assert(std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ia),
|
||||
std::equal_to<int>()));
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
std::equal_to<int>()));
|
||||
assert(std::equal(random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s),
|
||||
random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s),
|
||||
std::equal_to<int>()));
|
||||
|
||||
comparison_count = 0;
|
||||
assert(!std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s-1),
|
||||
counting_equals<int>));
|
||||
assert(comparison_count > 0);
|
||||
comparison_count = 0;
|
||||
assert(!std::equal(random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s),
|
||||
random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s-1),
|
||||
counting_equals<int>));
|
||||
assert(comparison_count == 0);
|
||||
#endif
|
||||
assert(!std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ib),
|
||||
std::equal_to<int>()));
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(!std::equal(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
input_iterator<const int*>(ib),
|
||||
input_iterator<const int*>(ib+s),
|
||||
std::equal_to<int>()));
|
||||
assert(!std::equal(random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia+s),
|
||||
random_access_iterator<const int*>(ib),
|
||||
random_access_iterator<const int*>(ib+s),
|
||||
std::equal_to<int>()));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter1, ForwardIterator Iter2>
|
||||
// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
|
||||
// Iter1
|
||||
// find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter1, class Iter2>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int b[] = {0};
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1)) == Iter1(ia+sa-1));
|
||||
int c[] = {0, 1};
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2)) == Iter1(ia+18));
|
||||
int d[] = {0, 1, 2};
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3)) == Iter1(ia+15));
|
||||
int e[] = {0, 1, 2, 3};
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4)) == Iter1(ia+11));
|
||||
int f[] = {0, 1, 2, 3, 4};
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5)) == Iter1(ia+6));
|
||||
int g[] = {0, 1, 2, 3, 4, 5};
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6)) == Iter1(ia));
|
||||
int h[] = {0, 1, 2, 3, 4, 5, 6};
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7)) == Iter1(ia+sa));
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b)) == Iter1(ia+sa));
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1)) == Iter1(ia));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter1, ForwardIterator Iter2,
|
||||
// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// Iter1
|
||||
// find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct count_equal
|
||||
{
|
||||
static unsigned count;
|
||||
template <class T>
|
||||
bool operator()(const T& x, const T& y)
|
||||
{++count; return x == y;}
|
||||
};
|
||||
|
||||
unsigned count_equal::count = 0;
|
||||
|
||||
template <class Iter1, class Iter2>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int b[] = {0};
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia+sa-1));
|
||||
assert(count_equal::count <= 1*(sa-1+1));
|
||||
int c[] = {0, 1};
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2), count_equal()) == Iter1(ia+18));
|
||||
assert(count_equal::count <= 2*(sa-2+1));
|
||||
int d[] = {0, 1, 2};
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3), count_equal()) == Iter1(ia+15));
|
||||
assert(count_equal::count <= 3*(sa-3+1));
|
||||
int e[] = {0, 1, 2, 3};
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4), count_equal()) == Iter1(ia+11));
|
||||
assert(count_equal::count <= 4*(sa-4+1));
|
||||
int f[] = {0, 1, 2, 3, 4};
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5), count_equal()) == Iter1(ia+6));
|
||||
assert(count_equal::count <= 5*(sa-5+1));
|
||||
int g[] = {0, 1, 2, 3, 4, 5};
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6), count_equal()) == Iter1(ia));
|
||||
assert(count_equal::count <= 6*(sa-6+1));
|
||||
int h[] = {0, 1, 2, 3, 4, 5, 6};
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7), count_equal()) == Iter1(ia+sa));
|
||||
assert(count_equal::count <= 7*(sa-7+1));
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b), count_equal()) == Iter1(ia+sa));
|
||||
assert(count_equal::count <= 0);
|
||||
count_equal::count = 0;
|
||||
assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia));
|
||||
assert(count_equal::count <= 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter1, ForwardIterator Iter2>
|
||||
// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
|
||||
// Iter1
|
||||
// find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[] = {1, 3, 5, 7};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sb)) ==
|
||||
input_iterator<const int*>(ia+1));
|
||||
int ic[] = {7};
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ic),
|
||||
forward_iterator<const int*>(ic + 1)) ==
|
||||
input_iterator<const int*>(ia+sa));
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ic),
|
||||
forward_iterator<const int*>(ic)) ==
|
||||
input_iterator<const int*>(ia+sa));
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ic),
|
||||
forward_iterator<const int*>(ic+1)) ==
|
||||
input_iterator<const int*>(ia));
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter1, ForwardIterator Iter2,
|
||||
// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// Iter1
|
||||
// find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[] = {1, 3, 5, 7};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sb),
|
||||
std::equal_to<int>()) ==
|
||||
input_iterator<const int*>(ia+1));
|
||||
int ic[] = {7};
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ic),
|
||||
forward_iterator<const int*>(ic + 1),
|
||||
std::equal_to<int>()) ==
|
||||
input_iterator<const int*>(ia+sa));
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ic),
|
||||
forward_iterator<const int*>(ic),
|
||||
std::equal_to<int>()) ==
|
||||
input_iterator<const int*>(ia+sa));
|
||||
assert(std::find_first_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ic),
|
||||
forward_iterator<const int*>(ic+1),
|
||||
std::equal_to<int>()) ==
|
||||
input_iterator<const int*>(ia));
|
||||
}
|
31
test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
Normal file
31
test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter, class T>
|
||||
// requires HasEqualTo<Iter::value_type, T>
|
||||
// Iter
|
||||
// find(Iter first, Iter last, const T& value);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned s = sizeof(ia)/sizeof(ia[0]);
|
||||
input_iterator<const int*> r = std::find(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s), 3);
|
||||
assert(*r == 3);
|
||||
r = std::find(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), 10);
|
||||
assert(r == input_iterator<const int*>(ia+s));
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// Iter
|
||||
// find_if(Iter first, Iter last, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned s = sizeof(ia)/sizeof(ia[0]);
|
||||
input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
std::bind2nd(std::equal_to<int>(), 3));
|
||||
assert(*r == 3);
|
||||
r = std::find_if(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
std::bind2nd(std::equal_to<int>(), 10));
|
||||
assert(r == input_iterator<const int*>(ia+s));
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// Iter
|
||||
// find_if_not(Iter first, Iter last, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned s = sizeof(ia)/sizeof(ia[0]);
|
||||
input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
std::bind2nd(std::not_equal_to<int>(), 3));
|
||||
assert(*r == 3);
|
||||
r = std::find_if_not(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia+s),
|
||||
std::bind2nd(std::not_equal_to<int>(), 10));
|
||||
assert(r == input_iterator<const int*>(ia+s));
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter, Callable<auto, Iter::reference> Function>
|
||||
// requires CopyConstructible<Function>
|
||||
// Function
|
||||
// for_each(Iter first, Iter last, Function f);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct for_each_test
|
||||
{
|
||||
for_each_test(int c) : count(c) {}
|
||||
int count;
|
||||
void operator()(int& i) {++i; ++count;}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned s = sizeof(ia)/sizeof(ia[0]);
|
||||
for_each_test f = std::for_each(input_iterator<int*>(ia),
|
||||
input_iterator<int*>(ia+s),
|
||||
for_each_test(0));
|
||||
assert(f.count == s);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ia[i] == i+1);
|
||||
}
|
@@ -0,0 +1,605 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class ForwardIterator1, class ForwardIterator2>
|
||||
// bool
|
||||
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
// ForwardIterator2 first2);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
const int ia[] = {0};
|
||||
const int ib[] = {0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + 0),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + 0),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + 0)) == true);
|
||||
#endif
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0};
|
||||
const int ib[] = {1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 0, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 1, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 2, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 2, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 2, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {1, 0, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {1, 2, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {2, 1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {2, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib + 1),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
|
||||
const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib + 1 ),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1)) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
|
||||
const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib)) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa)) == false);
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -0,0 +1,729 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
|
||||
// bool
|
||||
// is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
// ForwardIterator2 first2, BinaryPredicate pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int comparison_count = 0;
|
||||
template <typename T>
|
||||
bool counting_equals ( const T &a, const T &b ) {
|
||||
++comparison_count;
|
||||
return a == b;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
const int ia[] = {0};
|
||||
const int ib[] = {0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + 0),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0};
|
||||
const int ib[] = {1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 0};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 1};
|
||||
const int ib[] = {1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 0, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 1, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 1, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 2, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 2, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 0};
|
||||
const int ib[] = {1, 2, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {1, 0, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {1, 2, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {2, 1, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2};
|
||||
const int ib[] = {2, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 1};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 0, 1};
|
||||
const int ib[] = {1, 0, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib + 1),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
|
||||
const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == true);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == true);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib + 1),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
std::equal_to<const int>()) == false);
|
||||
comparison_count = 0;
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa - 1),
|
||||
counting_equals<const int>) == false);
|
||||
assert ( comparison_count > 0 );
|
||||
comparison_count = 0;
|
||||
assert(std::is_permutation(random_access_iterator<const int*>(ia),
|
||||
random_access_iterator<const int*>(ia + sa),
|
||||
random_access_iterator<const int*>(ib),
|
||||
random_access_iterator<const int*>(ib + sa - 1),
|
||||
counting_equals<const int>) == false);
|
||||
assert ( comparison_count == 0 );
|
||||
#endif
|
||||
}
|
||||
{
|
||||
const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
|
||||
const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
std::equal_to<const int>()) == false);
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::is_permutation(forward_iterator<const int*>(ia),
|
||||
forward_iterator<const int*>(ia + sa),
|
||||
forward_iterator<const int*>(ib),
|
||||
forward_iterator<const int*>(ib + sa),
|
||||
std::equal_to<const int>()) == false);
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template <class InputIterator, class Predicate>
|
||||
// bool
|
||||
// none_of(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct test1
|
||||
{
|
||||
bool operator()(const int& i) const
|
||||
{
|
||||
return i % 2 == 0;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int ia[] = {2, 4, 6, 8};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::none_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == false);
|
||||
assert(std::none_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == true);
|
||||
}
|
||||
{
|
||||
const int ia[] = {2, 4, 5, 8};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::none_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == false);
|
||||
assert(std::none_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == true);
|
||||
}
|
||||
{
|
||||
const int ia[] = {1, 3, 5, 7};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::none_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa), test1()) == true);
|
||||
assert(std::none_of(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia), test1()) == true);
|
||||
}
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter1, ForwardIterator Iter2>
|
||||
// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
|
||||
// Iter1
|
||||
// search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter1, class Iter2>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia)) == Iter1(ia));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1)) == Iter1(ia));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2)) == Iter1(ia+1));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2)) == Iter1(ia));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
|
||||
assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa)) == Iter1(ia+sa-1));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa)) == Iter1(ia+sa-3));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)) == Iter1(ia));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+sa-1));
|
||||
assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+1));
|
||||
int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
int ic[] = {1};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1)) == Iter1(ib+1));
|
||||
int id[] = {1, 2};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2)) == Iter1(ib+1));
|
||||
int ie[] = {1, 2, 3};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3)) == Iter1(ib+4));
|
||||
int ig[] = {1, 2, 3, 4};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4)) == Iter1(ib+8));
|
||||
int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
|
||||
const unsigned sh = sizeof(ih)/sizeof(ih[0]);
|
||||
int ii[] = {1, 1, 2};
|
||||
assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3)) == Iter1(ih+3));
|
||||
int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
|
||||
const unsigned sj = sizeof(ij)/sizeof(ij[0]);
|
||||
int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
|
||||
const unsigned sk = sizeof(ik)/sizeof(ik[0]);
|
||||
assert(std::search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk)) == Iter1(ij+6));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class ForwardIterator, class Size, class T>
|
||||
// ForwardIterator
|
||||
// search_n(ForwardIterator first, ForwardIterator last, Size count,
|
||||
// const T& value);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 0) == Iter(ia));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 0) == Iter(ia+0));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 0) == Iter(ia+sa));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 0) == Iter(ia+sa));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 3) == Iter(ia));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 3) == Iter(ia+3));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 3) == Iter(ia+sa));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 3) == Iter(ia+sa));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 5) == Iter(ia));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 5) == Iter(ia+5));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 5) == Iter(ia+sa));
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 5) == Iter(ia+sa));
|
||||
|
||||
int ib[] = {0, 0, 1, 1, 2, 2};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 0) == Iter(ib));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 0) == Iter(ib+0));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 0) == Iter(ib+0));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 0) == Iter(ib+sb));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 0) == Iter(ib+sb));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 1) == Iter(ib));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 1) == Iter(ib+2));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 1) == Iter(ib+2));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 1) == Iter(ib+sb));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 1) == Iter(ib+sb));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 2) == Iter(ib));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 2) == Iter(ib+4));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 2) == Iter(ib+4));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 2) == Iter(ib+sb));
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 2) == Iter(ib+sb));
|
||||
|
||||
int ic[] = {0, 0, 0};
|
||||
const unsigned sc = sizeof(ic)/sizeof(ic[0]);
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 0, 0) == Iter(ic));
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 1, 0) == Iter(ic));
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 2, 0) == Iter(ic));
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 3, 0) == Iter(ic));
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 4, 0) == Iter(ic+sc));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
}
|
@@ -0,0 +1,148 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class ForwardIterator, class Size, class T, class BinaryPredicate>
|
||||
// ForwardIterator
|
||||
// search_n(ForwardIterator first, ForwardIterator last, Size count,
|
||||
// const T& value, BinaryPredicate pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct count_equal
|
||||
{
|
||||
static unsigned count;
|
||||
template <class T>
|
||||
bool operator()(const T& x, const T& y)
|
||||
{++count; return x == y;}
|
||||
};
|
||||
|
||||
unsigned count_equal::count = 0;
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 0, count_equal()) == Iter(ia));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 0, count_equal()) == Iter(ia+0));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 0, count_equal()) == Iter(ia+sa));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 0, count_equal()) == Iter(ia+sa));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 3, count_equal()) == Iter(ia));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 3, count_equal()) == Iter(ia+3));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 3, count_equal()) == Iter(ia+sa));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 3, count_equal()) == Iter(ia+sa));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 5, count_equal()) == Iter(ia));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 5, count_equal()) == Iter(ia+5));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 5, count_equal()) == Iter(ia+sa));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 5, count_equal()) == Iter(ia+sa));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
|
||||
int ib[] = {0, 0, 1, 1, 2, 2};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 0, count_equal()) == Iter(ib));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 0, count_equal()) == Iter(ib+0));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 0, count_equal()) == Iter(ib+0));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 0, count_equal()) == Iter(ib+sb));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 0, count_equal()) == Iter(ib+sb));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 1, count_equal()) == Iter(ib));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 1, count_equal()) == Iter(ib+2));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 1, count_equal()) == Iter(ib+2));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 1, count_equal()) == Iter(ib+sb));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 1, count_equal()) == Iter(ib+sb));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 2, count_equal()) == Iter(ib));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 2, count_equal()) == Iter(ib+4));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 2, count_equal()) == Iter(ib+4));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 2, count_equal()) == Iter(ib+sb));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 2, count_equal()) == Iter(ib+sb));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
|
||||
int ic[] = {0, 0, 0};
|
||||
const unsigned sc = sizeof(ic)/sizeof(ic[0]);
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 0, 0, count_equal()) == Iter(ic));
|
||||
assert(count_equal::count <= sc);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 1, 0, count_equal()) == Iter(ic));
|
||||
assert(count_equal::count <= sc);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 2, 0, count_equal()) == Iter(ic));
|
||||
assert(count_equal::count <= sc);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 3, 0, count_equal()) == Iter(ic));
|
||||
assert(count_equal::count <= sc);
|
||||
count_equal::count = 0;
|
||||
assert(std::search_n(Iter(ic), Iter(ic+sc), 4, 0, count_equal()) == Iter(ic+sc));
|
||||
assert(count_equal::count <= sc);
|
||||
count_equal::count = 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter1, ForwardIterator Iter2>
|
||||
// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
|
||||
// Iter1
|
||||
// search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct count_equal
|
||||
{
|
||||
static unsigned count;
|
||||
template <class T>
|
||||
bool operator()(const T& x, const T& y)
|
||||
{++count; return x == y;}
|
||||
};
|
||||
|
||||
unsigned count_equal::count = 0;
|
||||
|
||||
template <class Iter1, class Iter2>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), count_equal()) == Iter1(ia));
|
||||
assert(count_equal::count <= 0);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), count_equal()) == Iter1(ia));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), count_equal()) == Iter1(ia+1));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), count_equal()) == Iter1(ia));
|
||||
assert(count_equal::count <= 0);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia));
|
||||
assert(count_equal::count <= 0);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-3));
|
||||
assert(count_equal::count <= sa*3);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia));
|
||||
assert(count_equal::count <= sa*sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
|
||||
assert(count_equal::count <= (sa-1)*sa);
|
||||
count_equal::count = 0;
|
||||
assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+1));
|
||||
assert(count_equal::count <= sa);
|
||||
count_equal::count = 0;
|
||||
int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
int ic[] = {1};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), count_equal()) == Iter1(ib+1));
|
||||
assert(count_equal::count <= sb);
|
||||
count_equal::count = 0;
|
||||
int id[] = {1, 2};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), count_equal()) == Iter1(ib+1));
|
||||
assert(count_equal::count <= sb*2);
|
||||
count_equal::count = 0;
|
||||
int ie[] = {1, 2, 3};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), count_equal()) == Iter1(ib+4));
|
||||
assert(count_equal::count <= sb*3);
|
||||
count_equal::count = 0;
|
||||
int ig[] = {1, 2, 3, 4};
|
||||
assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), count_equal()) == Iter1(ib+8));
|
||||
assert(count_equal::count <= sb*4);
|
||||
count_equal::count = 0;
|
||||
int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
|
||||
const unsigned sh = sizeof(ih)/sizeof(ih[0]);
|
||||
int ii[] = {1, 1, 2};
|
||||
assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), count_equal()) == Iter1(ih+3));
|
||||
assert(count_equal::count <= sh*3);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<forward_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, forward_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter1, InputIterator Iter2>
|
||||
// requires HasEqualTo<Iter1::value_type, Iter2::value_type>
|
||||
// pair<Iter1, Iter2>
|
||||
// mismatch(Iter1 first1, Iter1 last1, Iter2 first2);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
|
||||
typedef input_iterator<const int*> II;
|
||||
typedef random_access_iterator<const int*> RAI;
|
||||
|
||||
assert(std::mismatch(II(ia), II(ia + sa), II(ib))
|
||||
== (std::pair<II, II>(II(ia+3), II(ib+3))));
|
||||
|
||||
assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib))
|
||||
== (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
|
||||
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+sb))
|
||||
== (std::pair<II, II>(II(ia+3), II(ib+3))));
|
||||
|
||||
assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib+sb))
|
||||
== (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
|
||||
|
||||
|
||||
assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+2))
|
||||
== (std::pair<II, II>(II(ia+2), II(ib+2))));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<InputIterator Iter1, InputIterator Iter2,
|
||||
// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
|
||||
// requires CopyConstructible<Pred>
|
||||
// pair<Iter1, Iter2>
|
||||
// mismatch(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "counting_predicates.hpp"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
|
||||
const unsigned sb = sizeof(ib)/sizeof(ib[0]);
|
||||
|
||||
typedef input_iterator<const int*> II;
|
||||
typedef random_access_iterator<const int*> RAI;
|
||||
typedef std::equal_to<int> EQ;
|
||||
|
||||
assert(std::mismatch(II(ia), II(ia + sa), II(ib), EQ())
|
||||
== (std::pair<II, II>(II(ia+3), II(ib+3))));
|
||||
assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), EQ())
|
||||
== (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
|
||||
|
||||
binary_counting_predicate<EQ, int> bcp((EQ()));
|
||||
assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), std::ref(bcp))
|
||||
== (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
|
||||
assert(bcp.count() > 0 && bcp.count() < sa);
|
||||
bcp.reset();
|
||||
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib + sb), EQ())
|
||||
== (std::pair<II, II>(II(ia+3), II(ib+3))));
|
||||
assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib + sb), EQ())
|
||||
== (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3))));
|
||||
|
||||
assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib + sb), std::ref(bcp))
|
||||
== (std::pair<II, II>(II(ia+3), II(ib+3))));
|
||||
assert(bcp.count() > 0 && bcp.count() < std::min(sa, sb));
|
||||
#endif
|
||||
|
||||
assert(std::mismatch(ia, ia + sa, ib, EQ()) ==
|
||||
(std::pair<int*,int*>(ia+3,ib+3)));
|
||||
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::mismatch(ia, ia + sa, ib, ib + sb, EQ()) ==
|
||||
(std::pair<int*,int*>(ia+3,ib+3)));
|
||||
assert(std::mismatch(ia, ia + sa, ib, ib + 2, EQ()) ==
|
||||
(std::pair<int*,int*>(ia+2,ib+2)));
|
||||
#endif
|
||||
}
|
12
test/std/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
Normal file
12
test/std/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user