1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
13 // requires ShuffleIterator<Iter>
14 // && CopyConstructible<Compare>
16 // stable_sort(Iter first, Iter last, Compare comp);
26 #include "test_macros.h"
31 bool operator()(const P& x, const P& y)
35 std::mt19937 randomness;
39 bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y)
41 return x.first < y.first;
47 typedef std::pair<int, int> P;
53 for (int i = 0; i < N; ++i)
62 for (int i = 0; i < N - M; i += M)
64 std::shuffle(v.begin() + i, v.begin() + i + M, randomness);
66 std::stable_sort(v.begin(), v.end(), first_only());
67 assert(std::is_sorted(v.begin(), v.end()));
74 #if TEST_STD_VER >= 11
76 std::vector<std::unique_ptr<int> > v(1000);
77 for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
78 v[i].reset(new int(i));
79 std::stable_sort(v.begin(), v.end(), indirect_less());
80 assert(std::is_sorted(v.begin(), v.end(), indirect_less()));