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);
23 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
29 bool operator()(const P& x, const P& y)
33 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
37 bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y)
39 return x.first < y.first;
45 typedef std::pair<int, int> P;
51 for (int i = 0; i < N; ++i)
60 for (int i = 0; i < N - M; i += M)
62 std::random_shuffle(v.begin() + i, v.begin() + i + M);
64 std::stable_sort(v.begin(), v.end(), first_only());
65 assert(std::is_sorted(v.begin(), v.end()));
72 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
74 std::vector<std::unique_ptr<int> > v(1000);
75 for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
76 v[i].reset(new int(i));
77 std::stable_sort(v.begin(), v.end(), indirect_less());
78 assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
83 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES