//===----------------------------------------------------------------------===// // // 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. // //===----------------------------------------------------------------------===// // // template Compare> // requires ShuffleIterator // && CopyConstructible // void // sort(Iter first, Iter last, Compare comp); #include #include #include #include #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include struct indirect_less { template bool operator()(const P& x, const P& y) {return *x < *y;} }; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES int main() { { std::vector v(1000); for (int i = 0; i < v.size(); ++i) v[i] = i; std::sort(v.begin(), v.end(), std::greater()); std::reverse(v.begin(), v.end()); assert(std::is_sorted(v.begin(), v.end())); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector > v(1000); for (int i = 0; i < v.size(); ++i) v[i].reset(new int(i)); std::sort(v.begin(), v.end(), indirect_less()); assert(std::is_sorted(v.begin(), v.end(), indirect_less())); assert(*v[0] == 0); assert(*v[1] == 1); assert(*v[2] == 2); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }