| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | namespace jitstd |
| 10 | { |
| 11 | |
| 12 | template <typename T> |
| 13 | void swap(T& a, T& b) |
| 14 | { |
| 15 | T t(a); |
| 16 | a = b; |
| 17 | b = t; |
| 18 | } |
| 19 | |
| 20 | template <typename Arg, typename Result> |
| 21 | struct unary_function |
| 22 | { |
| 23 | typedef Arg argument_type; |
| 24 | typedef Result result_type; |
| 25 | }; |
| 26 | |
| 27 | template <typename Arg1, typename Arg2, typename Result> |
| 28 | struct binary_function |
| 29 | { |
| 30 | typedef Arg1 first_argument_type; |
| 31 | typedef Arg2 second_argument_type; |
| 32 | typedef Result result_type; |
| 33 | }; |
| 34 | |
| 35 | template <typename T> |
| 36 | struct greater : binary_function<T, T, bool> |
| 37 | { |
| 38 | bool operator()(const T& lhs, const T& rhs) const |
| 39 | { |
| 40 | return lhs > rhs; |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | template <typename T> |
| 45 | struct equal_to : binary_function<T, T, bool> |
| 46 | { |
| 47 | bool operator()(const T& lhs, const T& rhs) const |
| 48 | { |
| 49 | return lhs == rhs; |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | template <typename T> |
| 54 | struct identity : unary_function<T, T> |
| 55 | { |
| 56 | const T& operator()(const T& op) const |
| 57 | { |
| 58 | return op; |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | } // end of namespace jitstd. |
| 63 | |