1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <algorithm> 11 12 // template<LessThanComparable T> 13 // pair<const T&, const T&> 14 // minmax(const T& a, const T& b); 15 16 #include <algorithm> 17 #include <cassert> 18 19 template <class T> 20 void 21 test(const T& a, const T& b, const T& x, const T& y) 22 { 23 std::pair<const T&, const T&> p = std::minmax(a, b); 24 assert(&p.first == &x); 25 assert(&p.second == &y); 26 } 27 28 int main() 29 { 30 { 31 int x = 0; 32 int y = 0; 33 test(x, y, x, y); 34 test(y, x, y, x); 35 } 36 { 37 int x = 0; 38 int y = 1; 39 test(x, y, x, y); 40 test(y, x, x, y); 41 } 42 { 43 int x = 1; 44 int y = 0; 45 test(x, y, y, x); 46 test(y, x, y, x); 47 } 48 } 49