libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
46
test/algorithms/alg.sorting/alg.min.max/max.pass.cpp
Normal file
46
test/algorithms/alg.sorting/alg.min.max/max.pass.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<LessThanComparable T>
|
||||
// const T&
|
||||
// max(const T& a, const T& b);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test(const T& a, const T& b, const T& x)
|
||||
{
|
||||
assert(&std::max(a, b) == &x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
test(x, y, x);
|
||||
test(y, x, y);
|
||||
}
|
||||
{
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
test(x, y, y);
|
||||
test(y, x, y);
|
||||
}
|
||||
{
|
||||
int x = 1;
|
||||
int y = 0;
|
||||
test(x, y, x);
|
||||
test(y, x, x);
|
||||
}
|
||||
}
|
48
test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp
Normal file
48
test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T, StrictWeakOrder<auto, T> Compare>
|
||||
// requires !SameType<T, Compare> && CopyConstructible<Compare>
|
||||
// const T&
|
||||
// max(const T& a, const T& b, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
template <class T, class C>
|
||||
void
|
||||
test(const T& a, const T& b, C c, const T& x)
|
||||
{
|
||||
assert(&std::max(a, b, c) == &x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
test(x, y, std::greater<int>(), x);
|
||||
test(y, x, std::greater<int>(), y);
|
||||
}
|
||||
{
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
test(x, y, std::greater<int>(), x);
|
||||
test(y, x, std::greater<int>(), x);
|
||||
}
|
||||
{
|
||||
int x = 1;
|
||||
int y = 0;
|
||||
test(x, y, std::greater<int>(), y);
|
||||
test(y, x, std::greater<int>(), y);
|
||||
}
|
||||
}
|
66
test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
Normal file
66
test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter>
|
||||
// requires LessThanComparable<Iter::value_type>
|
||||
// Iter
|
||||
// max_element(Iter first, Iter last);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last)
|
||||
{
|
||||
Iter i = std::max_element(first, last);
|
||||
if (first != last)
|
||||
{
|
||||
for (Iter j = first; j != last; ++j)
|
||||
assert(!(*i < *j));
|
||||
}
|
||||
else
|
||||
assert(i == last);
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(unsigned N)
|
||||
{
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = i;
|
||||
std::random_shuffle(a, a+N);
|
||||
test(Iter(a), Iter(a+N));
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<Iter>(0);
|
||||
test<Iter>(1);
|
||||
test<Iter>(2);
|
||||
test<Iter>(3);
|
||||
test<Iter>(10);
|
||||
test<Iter>(1000);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
|
||||
// requires CopyConstructible<Compare>
|
||||
// Iter
|
||||
// max_element(Iter first, Iter last, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last)
|
||||
{
|
||||
Iter i = std::max_element(first, last, std::greater<int>());
|
||||
if (first != last)
|
||||
{
|
||||
for (Iter j = first; j != last; ++j)
|
||||
assert(!std::greater<int>()(*i, *j));
|
||||
}
|
||||
else
|
||||
assert(i == last);
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(unsigned N)
|
||||
{
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = i;
|
||||
std::random_shuffle(a, a+N);
|
||||
test(Iter(a), Iter(a+N));
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<Iter>(0);
|
||||
test<Iter>(1);
|
||||
test<Iter>(2);
|
||||
test<Iter>(3);
|
||||
test<Iter>(10);
|
||||
test<Iter>(1000);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template <class T>
|
||||
// T
|
||||
// max(initializer_list<T> t);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#error max(initializer_list<T> t) is not implemented
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T, class Compare>
|
||||
// T
|
||||
// max(initializer_list<T> t, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#error max(initializer_list<T> t, Compare comp) is not implemented
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
46
test/algorithms/alg.sorting/alg.min.max/min.pass.cpp
Normal file
46
test/algorithms/alg.sorting/alg.min.max/min.pass.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<LessThanComparable T>
|
||||
// const T&
|
||||
// min(const T& a, const T& b);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test(const T& a, const T& b, const T& x)
|
||||
{
|
||||
assert(&std::min(a, b) == &x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
test(x, y, x);
|
||||
test(y, x, y);
|
||||
}
|
||||
{
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
test(x, y, x);
|
||||
test(y, x, x);
|
||||
}
|
||||
{
|
||||
int x = 1;
|
||||
int y = 0;
|
||||
test(x, y, y);
|
||||
test(y, x, y);
|
||||
}
|
||||
}
|
48
test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp
Normal file
48
test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T, StrictWeakOrder<auto, T> Compare>
|
||||
// requires !SameType<T, Compare> && CopyConstructible<Compare>
|
||||
// const T&
|
||||
// min(const T& a, const T& b, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
template <class T, class C>
|
||||
void
|
||||
test(const T& a, const T& b, C c, const T& x)
|
||||
{
|
||||
assert(&std::min(a, b, c) == &x);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
test(x, y, std::greater<int>(), x);
|
||||
test(y, x, std::greater<int>(), y);
|
||||
}
|
||||
{
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
test(x, y, std::greater<int>(), y);
|
||||
test(y, x, std::greater<int>(), y);
|
||||
}
|
||||
{
|
||||
int x = 1;
|
||||
int y = 0;
|
||||
test(x, y, std::greater<int>(), x);
|
||||
test(y, x, std::greater<int>(), x);
|
||||
}
|
||||
}
|
66
test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
Normal file
66
test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter>
|
||||
// requires LessThanComparable<Iter::value_type>
|
||||
// Iter
|
||||
// min_element(Iter first, Iter last);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last)
|
||||
{
|
||||
Iter i = std::min_element(first, last);
|
||||
if (first != last)
|
||||
{
|
||||
for (Iter j = first; j != last; ++j)
|
||||
assert(!(*j < *i));
|
||||
}
|
||||
else
|
||||
assert(i == last);
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(unsigned N)
|
||||
{
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = i;
|
||||
std::random_shuffle(a, a+N);
|
||||
test(Iter(a), Iter(a+N));
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<Iter>(0);
|
||||
test<Iter>(1);
|
||||
test<Iter>(2);
|
||||
test<Iter>(3);
|
||||
test<Iter>(10);
|
||||
test<Iter>(1000);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
|
||||
// requires CopyConstructible<Compare>
|
||||
// Iter
|
||||
// min_element(Iter first, Iter last, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last)
|
||||
{
|
||||
Iter i = std::min_element(first, last, std::greater<int>());
|
||||
if (first != last)
|
||||
{
|
||||
for (Iter j = first; j != last; ++j)
|
||||
assert(!std::greater<int>()(*j, *i));
|
||||
}
|
||||
else
|
||||
assert(i == last);
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(unsigned N)
|
||||
{
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = i;
|
||||
std::random_shuffle(a, a+N);
|
||||
test(Iter(a), Iter(a+N));
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<Iter>(0);
|
||||
test<Iter>(1);
|
||||
test<Iter>(2);
|
||||
test<Iter>(3);
|
||||
test<Iter>(10);
|
||||
test<Iter>(1000);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T>
|
||||
// T
|
||||
// min(initializer_list<T> t);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#error min(initializer_list<T> t) is not implemented
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T, class Compare>
|
||||
// T
|
||||
// min(initializer_list<T> t, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#error min(initializer_list<T> t, Compare comp) is not implemented
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
48
test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
Normal file
48
test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<LessThanComparable T>
|
||||
// pair<const T&, const T&>
|
||||
// minmax(const T& a, const T& b);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test(const T& a, const T& b, const T& x, const T& y)
|
||||
{
|
||||
std::pair<const T&, const T&> p = std::minmax(a, b);
|
||||
assert(&p.first == &x);
|
||||
assert(&p.second == &y);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
test(x, y, x, y);
|
||||
test(y, x, y, x);
|
||||
}
|
||||
{
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
test(x, y, x, y);
|
||||
test(y, x, x, y);
|
||||
}
|
||||
{
|
||||
int x = 1;
|
||||
int y = 0;
|
||||
test(x, y, y, x);
|
||||
test(y, x, y, x);
|
||||
}
|
||||
}
|
50
test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
Normal file
50
test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T, StrictWeakOrder<auto, T> Compare>
|
||||
// requires !SameType<T, Compare> && CopyConstructible<Compare>
|
||||
// pair<const T&, const T&>
|
||||
// minmax(const T& a, const T& b, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
template <class T, class C>
|
||||
void
|
||||
test(const T& a, const T& b, C c, const T& x, const T& y)
|
||||
{
|
||||
std::pair<const T&, const T&> p = std::minmax(a, b, c);
|
||||
assert(&p.first == &x);
|
||||
assert(&p.second == &y);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
test(x, y, std::greater<int>(), x, y);
|
||||
test(y, x, std::greater<int>(), y, x);
|
||||
}
|
||||
{
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
test(x, y, std::greater<int>(), x, y);
|
||||
test(y, x, std::greater<int>(), x, y);
|
||||
}
|
||||
{
|
||||
int x = 1;
|
||||
int y = 0;
|
||||
test(x, y, std::greater<int>(), y, x);
|
||||
test(y, x, std::greater<int>(), y, x);
|
||||
}
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter>
|
||||
// requires LessThanComparable<Iter::value_type>
|
||||
// pair<Iter, Iter>
|
||||
// minmax_element(Iter first, Iter last);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last)
|
||||
{
|
||||
std::pair<Iter, Iter> p = std::minmax_element(first, last);
|
||||
if (first != last)
|
||||
{
|
||||
for (Iter j = first; j != last; ++j)
|
||||
{
|
||||
assert(!(*j < *p.first));
|
||||
assert(!(*p.second < *j));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(p.first == last);
|
||||
assert(p.second == last);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(unsigned N)
|
||||
{
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = i;
|
||||
std::random_shuffle(a, a+N);
|
||||
test(Iter(a), Iter(a+N));
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<Iter>(0);
|
||||
test<Iter>(1);
|
||||
test<Iter>(2);
|
||||
test<Iter>(3);
|
||||
test<Iter>(10);
|
||||
test<Iter>(1000);
|
||||
{
|
||||
const unsigned N = 100;
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = 5;
|
||||
std::random_shuffle(a, a+N);
|
||||
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N));
|
||||
assert(base(p.first) == a);
|
||||
assert(base(p.second) == a+N-1);
|
||||
delete [] a;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
|
||||
// requires CopyConstructible<Compare>
|
||||
// pair<Iter, Iter>
|
||||
// minmax_element(Iter first, Iter last, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last)
|
||||
{
|
||||
typedef std::greater<int> Compare;
|
||||
Compare comp;
|
||||
std::pair<Iter, Iter> p = std::minmax_element(first, last, comp);
|
||||
if (first != last)
|
||||
{
|
||||
for (Iter j = first; j != last; ++j)
|
||||
{
|
||||
assert(!comp(*j, *p.first));
|
||||
assert(!comp(*p.second, *j));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(p.first == last);
|
||||
assert(p.second == last);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(unsigned N)
|
||||
{
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = i;
|
||||
std::random_shuffle(a, a+N);
|
||||
test(Iter(a), Iter(a+N));
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<Iter>(0);
|
||||
test<Iter>(1);
|
||||
test<Iter>(2);
|
||||
test<Iter>(3);
|
||||
test<Iter>(10);
|
||||
test<Iter>(1000);
|
||||
{
|
||||
const unsigned N = 100;
|
||||
int* a = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
a[i] = 5;
|
||||
std::random_shuffle(a, a+N);
|
||||
typedef std::greater<int> Compare;
|
||||
Compare comp;
|
||||
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp);
|
||||
assert(base(p.first) == a);
|
||||
assert(base(p.second) == a+N-1);
|
||||
delete [] a;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<const int*> >();
|
||||
test<bidirectional_iterator<const int*> >();
|
||||
test<random_access_iterator<const int*> >();
|
||||
test<const int*>();
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T>
|
||||
// pair<const T&, const T&>
|
||||
// minmax(initializer_list<T> t);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#error minmax(initializer_list<T> t) is not implemented
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
|
||||
// template<class T, class Compare>
|
||||
// pair<const T&, const T&>
|
||||
// minmax(initializer_list<T> t, Compare comp);
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#error minmax(initializer_list<T> t, Compare comp) is not implemented
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user