diff options
author | andrew@webrtc.org <andrew@webrtc.org> | 2014-12-17 22:56:09 +0000 |
---|---|---|
committer | andrew@webrtc.org <andrew@webrtc.org> | 2014-12-17 22:56:09 +0000 |
commit | 0ab42bc3f6438db4194b3d77b66629413c7038da (patch) | |
tree | 7a4988639e524d54e221a581bb1e84b7f8dad446 /webrtc/base/safe_conversions.h | |
parent | bc03192560a591ad33c84c707f43710d98e330a3 (diff) | |
download | webrtc-0ab42bc3f6438db4194b3d77b66629413c7038da.tar.gz |
Make safe_conversions suitable for rtc_base_approved.
Since we want to use checked_cast in WavReader.
R=kwiberg@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/32839004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7937 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/base/safe_conversions.h')
-rw-r--r-- | webrtc/base/safe_conversions.h | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/webrtc/base/safe_conversions.h b/webrtc/base/safe_conversions.h index f6cb24e412..7fc67cb67a 100644 --- a/webrtc/base/safe_conversions.h +++ b/webrtc/base/safe_conversions.h @@ -15,20 +15,11 @@ #include <limits> -#include "webrtc/base/common.h" -#include "webrtc/base/logging.h" +#include "webrtc/base/checks.h" #include "webrtc/base/safe_conversions_impl.h" namespace rtc { -inline void Check(bool condition) { - if (!condition) { - LOG(LS_ERROR) << "CHECK failed."; - Break(); - // The program should have crashed at this point. - } -} - // Convenience function that returns true if the supplied value is in range // for the destination type. template <typename Dst, typename Src> @@ -41,7 +32,7 @@ inline bool IsValueInRangeForNumericType(Src value) { // overflow or underflow. NaN source will always trigger a CHECK. template <typename Dst, typename Src> inline Dst checked_cast(Src value) { - Check(IsValueInRangeForNumericType<Dst>(value)); + CHECK(IsValueInRangeForNumericType<Dst>(value)); return static_cast<Dst>(value); } @@ -66,11 +57,11 @@ inline Dst saturated_cast(Src value) { // Should fail only on attempting to assign NaN to a saturated integer. case internal::TYPE_INVALID: - Check(false); + FATAL(); return std::numeric_limits<Dst>::max(); } - Check(false); // NOTREACHED(); + FATAL(); return static_cast<Dst>(value); } |