kwiberg | 8a44e1d | 2016-11-01 12:04:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
kwiberg | 0d4e068 | 2017-04-10 22:44:07 -0700 | [diff] [blame] | 11 | // This file defines six constexpr functions: |
kwiberg | 8a44e1d | 2016-11-01 12:04:26 -0700 | [diff] [blame] | 12 | // |
kwiberg | 93ecc5d | 2017-06-26 01:31:31 -0700 | [diff] [blame] | 13 | // rtc::SafeEq // == |
| 14 | // rtc::SafeNe // != |
| 15 | // rtc::SafeLt // < |
| 16 | // rtc::SafeLe // <= |
| 17 | // rtc::SafeGt // > |
| 18 | // rtc::SafeGe // >= |
kwiberg | 8a44e1d | 2016-11-01 12:04:26 -0700 | [diff] [blame] | 19 | // |
| 20 | // They each accept two arguments of arbitrary types, and in almost all cases, |
| 21 | // they simply call the appropriate comparison operator. However, if both |
| 22 | // arguments are integers, they don't compare them using C++'s quirky rules, |
| 23 | // but instead adhere to the true mathematical definitions. It is as if the |
| 24 | // arguments were first converted to infinite-range signed integers, and then |
| 25 | // compared, although of course nothing expensive like that actually takes |
| 26 | // place. In practice, for signed/signed and unsigned/unsigned comparisons and |
| 27 | // some mixed-signed comparisons with a compile-time constant, the overhead is |
| 28 | // zero; in the remaining cases, it is just a few machine instructions (no |
| 29 | // branches). |
| 30 | |
| 31 | #ifndef WEBRTC_BASE_SAFE_COMPARE_H_ |
| 32 | #define WEBRTC_BASE_SAFE_COMPARE_H_ |
| 33 | |
kwiberg | 8a44e1d | 2016-11-01 12:04:26 -0700 | [diff] [blame] | 34 | |
Henrik Kjellander | 6776518 | 2017-06-28 20:58:07 +0200 | [diff] [blame] | 35 | // This header is deprecated and is just left here temporarily during |
| 36 | // refactoring. See https://bugs.webrtc.org/7634 for more details. |
| 37 | #include "webrtc/rtc_base/safe_compare.h" |
kwiberg | 8a44e1d | 2016-11-01 12:04:26 -0700 | [diff] [blame] | 38 | |
| 39 | #endif // WEBRTC_BASE_SAFE_COMPARE_H_ |