Revert "Revert "Merge to upstream r304942.""
This reverts commit 38a0d5af7e.
Test: make checkbuild
Test: ./run_tests.py
Test: ./run_tests.py --bitness 64
This commit is contained in:
@@ -16,10 +16,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
@@ -38,8 +37,7 @@ test()
|
||||
assert(ia[i] == ib[i]);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test1()
|
||||
@@ -55,8 +53,7 @@ test1()
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
assert(*ib[i] == static_cast<int>(i));
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -95,7 +92,7 @@ int main()
|
||||
test<const int*, random_access_iterator<int*> >();
|
||||
test<const int*, int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
test1<input_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
|
||||
test1<input_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
|
||||
test1<input_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
|
||||
@@ -130,5 +127,5 @@ int main()
|
||||
test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
}
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
@@ -38,8 +37,7 @@ test()
|
||||
assert(ia[i] == ib[i]);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test1()
|
||||
@@ -55,8 +53,7 @@ test1()
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
assert(*ib[i] == static_cast<int>(i));
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -72,7 +69,7 @@ int main()
|
||||
test<const int*, random_access_iterator<int*> >();
|
||||
test<const int*, int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
|
||||
test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
|
||||
test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
|
||||
@@ -84,5 +81,5 @@ int main()
|
||||
test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
// REQUIRES: c++98 || c++03 || c++11 || c++14
|
||||
|
||||
// template<RandomAccessIterator Iter>
|
||||
// requires ShuffleIterator<Iter>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <algorithm>
|
||||
// REQUIRES: c++98 || c++03 || c++11 || c++14
|
||||
|
||||
// template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand>
|
||||
// requires ShuffleIterator<Iter>
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
@@ -39,8 +38,7 @@ test()
|
||||
assert(ia[5] == 4);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
template <class Iter>
|
||||
void
|
||||
test1()
|
||||
@@ -62,8 +60,7 @@ test1()
|
||||
assert(*ia[4] == 3);
|
||||
assert(*ia[5] == 4);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -72,12 +69,10 @@ int main()
|
||||
test<random_access_iterator<int*> >();
|
||||
test<int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
test1<forward_iterator<std::unique_ptr<int>*> >();
|
||||
test1<bidirectional_iterator<std::unique_ptr<int>*> >();
|
||||
test1<random_access_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*>();
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
bool equalToTwo(int v) { return v == 2; }
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test()
|
||||
@@ -28,8 +30,8 @@ test()
|
||||
int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[sa];
|
||||
OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
|
||||
std::bind2nd(std::equal_to<int>(), 2));
|
||||
OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa),
|
||||
OutIter(ib), equalToTwo);
|
||||
assert(base(r) == ib + sa-3);
|
||||
assert(ib[0] == 0);
|
||||
assert(ib[1] == 1);
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
#include "counting_predicates.hpp"
|
||||
|
||||
@@ -46,8 +45,7 @@ test()
|
||||
assert(cp.count() == sa);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
struct pred
|
||||
{
|
||||
bool operator()(const std::unique_ptr<int>& i) {return *i == 2;}
|
||||
@@ -77,8 +75,7 @@ test1()
|
||||
assert(*ia[4] == 3);
|
||||
assert(*ia[5] == 4);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -87,12 +84,10 @@ int main()
|
||||
test<random_access_iterator<int*> >();
|
||||
test<int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
test1<forward_iterator<std::unique_ptr<int>*> >();
|
||||
test1<bidirectional_iterator<std::unique_ptr<int>*> >();
|
||||
test1<random_access_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*>();
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
bool equalToTwo(int v) { return v == 2; }
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test()
|
||||
@@ -30,8 +32,8 @@ test()
|
||||
int ia[] = {0, 1, 2, 3, 4};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[sa] = {0};
|
||||
OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
|
||||
std::bind2nd(std::equal_to<int>(), 2), 5);
|
||||
OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa),
|
||||
OutIter(ib), equalToTwo, 5);
|
||||
assert(base(r) == ib + sa);
|
||||
assert(ib[0] == 0);
|
||||
assert(ib[1] == 1);
|
||||
|
||||
@@ -22,13 +22,15 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
bool equalToTwo(int v) { return v == 2; }
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {0, 1, 2, 3, 4};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5);
|
||||
std::replace_if(Iter(ia), Iter(ia+sa), equalToTwo, 5);
|
||||
assert(ia[0] == 0);
|
||||
assert(ia[1] == 1);
|
||||
assert(ia[2] == 5);
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
template<class Iter1, class Iter2>
|
||||
@@ -38,8 +37,7 @@ test()
|
||||
assert(j[2] == 3);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
template<class Iter1, class Iter2>
|
||||
void
|
||||
test1()
|
||||
@@ -59,8 +57,7 @@ test1()
|
||||
assert(*j[1] == 2);
|
||||
assert(*j[2] == 3);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
|
||||
void test2()
|
||||
{
|
||||
@@ -131,8 +128,7 @@ int main()
|
||||
test<int*, random_access_iterator<int*> >();
|
||||
test<int*, int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
test1<forward_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
|
||||
test1<forward_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
|
||||
test1<forward_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
|
||||
@@ -152,8 +148,7 @@ int main()
|
||||
test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
|
||||
test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
|
||||
test2();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int plusOne(int v) { return v + 1; }
|
||||
|
||||
template <class InIter, class OutIter>
|
||||
void
|
||||
test()
|
||||
@@ -28,8 +30,8 @@ test()
|
||||
int ia[] = {0, 1, 2, 3, 4};
|
||||
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
||||
int ib[sa] = {0};
|
||||
OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib),
|
||||
std::bind2nd(std::plus<int>(), 1));
|
||||
OutIter r = std::transform(InIter(ia), InIter(ia+sa),
|
||||
OutIter(ib), plusOne);
|
||||
assert(base(r) == ib + sa);
|
||||
assert(ib[0] == 1);
|
||||
assert(ib[1] == 2);
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
@@ -84,7 +83,7 @@ test()
|
||||
assert(ii[2] == 2);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
|
||||
struct do_nothing
|
||||
{
|
||||
@@ -168,8 +167,7 @@ test1()
|
||||
assert(*ii[1] == 1);
|
||||
assert(*ii[2] == 2);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -178,12 +176,10 @@ int main()
|
||||
test<random_access_iterator<int*> >();
|
||||
test<int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
test1<forward_iterator<Ptr*> >();
|
||||
test1<bidirectional_iterator<Ptr*> >();
|
||||
test1<random_access_iterator<Ptr*> >();
|
||||
test1<Ptr*>();
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct count_equal
|
||||
@@ -110,7 +109,7 @@ test()
|
||||
assert(count_equal::count == si-1);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
|
||||
struct do_nothing
|
||||
{
|
||||
@@ -210,8 +209,7 @@ test1()
|
||||
assert(*ii[2] == 2);
|
||||
assert(count_equal::count == si-1);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // TEST_STD_VER >= 11
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -220,12 +218,10 @@ int main()
|
||||
test<random_access_iterator<int*> >();
|
||||
test<int*>();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
test1<forward_iterator<Ptr*> >();
|
||||
test1<bidirectional_iterator<Ptr*> >();
|
||||
test1<random_access_iterator<Ptr*> >();
|
||||
test1<Ptr*>();
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -20,17 +20,24 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct eq {
|
||||
eq (int val) : v(val) {}
|
||||
bool operator () (int v2) const { return v == v2; }
|
||||
int v;
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
eq(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);
|
||||
eq(7)) == 0);
|
||||
assert(std::count_if(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia),
|
||||
std::bind2nd(std::equal_to<int>(),2)) == 0);
|
||||
eq(2)) == 0);
|
||||
}
|
||||
|
||||
@@ -20,16 +20,22 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct eq {
|
||||
eq (int val) : v(val) {}
|
||||
bool operator () (int v2) const { return v == v2; }
|
||||
int v;
|
||||
};
|
||||
|
||||
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));
|
||||
eq(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));
|
||||
eq(10));
|
||||
assert(r == input_iterator<const int*>(ia+s));
|
||||
}
|
||||
|
||||
@@ -20,16 +20,23 @@
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
struct ne {
|
||||
ne (int val) : v(val) {}
|
||||
bool operator () (int v2) const { return v != v2; }
|
||||
int v;
|
||||
};
|
||||
|
||||
|
||||
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));
|
||||
ne(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));
|
||||
ne(10));
|
||||
assert(r == input_iterator<const int*>(ia+s));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
|
||||
// template<class InputIterator, class Size, class Function>
|
||||
// InputIterator for_each_n(InputIterator first, Size n, 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()
|
||||
{
|
||||
typedef input_iterator<int*> Iter;
|
||||
int ia[] = {0, 1, 2, 3, 4, 5};
|
||||
const unsigned s = sizeof(ia)/sizeof(ia[0]);
|
||||
|
||||
{
|
||||
auto f = for_each_test(0);
|
||||
Iter it = std::for_each_n(Iter(ia), 0, std::ref(f));
|
||||
assert(it == Iter(ia));
|
||||
assert(f.count == 0);
|
||||
}
|
||||
|
||||
{
|
||||
auto f = for_each_test(0);
|
||||
Iter it = std::for_each_n(Iter(ia), s, std::ref(f));
|
||||
|
||||
assert(it == Iter(ia+s));
|
||||
assert(f.count == s);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ia[i] == static_cast<int>(i+1));
|
||||
}
|
||||
|
||||
{
|
||||
auto f = for_each_test(0);
|
||||
Iter it = std::for_each_n(Iter(ia), 1, std::ref(f));
|
||||
|
||||
assert(it == Iter(ia+1));
|
||||
assert(f.count == 1);
|
||||
for (unsigned i = 0; i < 1; ++i)
|
||||
assert(ia[i] == static_cast<int>(i+2));
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@
|
||||
#include <functional>
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct indirect_less
|
||||
{
|
||||
@@ -29,7 +29,6 @@ struct indirect_less
|
||||
{return *x < *y;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
std::mt19937 randomness;
|
||||
|
||||
@@ -53,7 +52,7 @@ int main()
|
||||
{
|
||||
test(1000);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
const int N = 1000;
|
||||
std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
|
||||
@@ -68,5 +67,5 @@ int main()
|
||||
}
|
||||
delete [] ia;
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
#include <functional>
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct indirect_less
|
||||
{
|
||||
template <class P>
|
||||
@@ -29,8 +30,6 @@ struct indirect_less
|
||||
{return *x < *y;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
std::mt19937 randomness;
|
||||
|
||||
void test(int N)
|
||||
@@ -51,7 +50,7 @@ int main()
|
||||
{
|
||||
test(1000);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
const int N = 1000;
|
||||
std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
|
||||
@@ -65,5 +64,5 @@ int main()
|
||||
}
|
||||
delete [] ia;
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
#include <functional>
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct indirect_less
|
||||
{
|
||||
template <class P>
|
||||
@@ -28,8 +29,6 @@ struct indirect_less
|
||||
{return *x < *y;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
std::mt19937 randomness;
|
||||
|
||||
void test(int N)
|
||||
@@ -53,7 +52,7 @@ int main()
|
||||
test(10);
|
||||
test(1000);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
const int N = 1000;
|
||||
std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
|
||||
@@ -65,5 +64,5 @@ int main()
|
||||
assert(std::is_sorted(ia, ia+N, indirect_less()));
|
||||
delete [] ia;
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct indirect_less
|
||||
{
|
||||
template <class P>
|
||||
@@ -31,8 +32,6 @@ struct indirect_less
|
||||
{return *x < *y;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
std::mt19937 randomness;
|
||||
|
||||
void
|
||||
@@ -78,7 +77,7 @@ int main()
|
||||
test(1000);
|
||||
test(1009);
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
std::vector<std::unique_ptr<int> > v(1000);
|
||||
for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
|
||||
@@ -86,5 +85,5 @@ int main()
|
||||
std::nth_element(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
|
||||
assert(static_cast<std::size_t>(*v[v.size()/2]) == v.size()/2);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct indirect_less
|
||||
{
|
||||
template <class P>
|
||||
@@ -31,8 +32,6 @@ struct indirect_less
|
||||
{return *x < *y;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
std::mt19937 randomness;
|
||||
|
||||
void
|
||||
@@ -84,7 +83,7 @@ int main()
|
||||
test_larger_sorts(1009);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
std::vector<std::unique_ptr<int> > v(1000);
|
||||
for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
|
||||
@@ -93,5 +92,5 @@ int main()
|
||||
for (int i = 0; static_cast<std::size_t>(i) < v.size()/2; ++i)
|
||||
assert(*v[i] == i);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct indirect_less
|
||||
{
|
||||
template <class P>
|
||||
@@ -30,8 +31,6 @@ struct indirect_less
|
||||
{return *x < *y;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -43,7 +42,7 @@ int main()
|
||||
assert(std::is_sorted(v.begin(), v.end()));
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
std::vector<std::unique_ptr<int> > v(1000);
|
||||
for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
|
||||
@@ -54,5 +53,5 @@ int main()
|
||||
assert(*v[1] == 1);
|
||||
assert(*v[2] == 2);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
#include <random>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#include <memory>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct indirect_less
|
||||
{
|
||||
template <class P>
|
||||
@@ -31,8 +32,6 @@ struct indirect_less
|
||||
{return *x < *y;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
std::mt19937 randomness;
|
||||
|
||||
struct first_only
|
||||
@@ -72,7 +71,7 @@ int main()
|
||||
{
|
||||
test();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
std::vector<std::unique_ptr<int> > v(1000);
|
||||
for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
|
||||
@@ -83,5 +82,5 @@ int main()
|
||||
assert(*v[1] == 1);
|
||||
assert(*v[2] == 2);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user