aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2018-06-13 11:41:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-13 16:23:46 +0000
commitc6530d1e5ecce640e0255d66a01f9db73add7df9 (patch)
tree49f59cfff77e9729c0410348b096a00399c7676d /include/private
parent02a18b60f6a3e2bbdb4f3bdef6cb5b26877798e0 (diff)
use std::enable_if instead of assert()
Crazy? Genius? Change-Id: I6033ab5f1af1a6bee84c27025b988e1143d59293 Reviewed-on: https://skia-review.googlesource.com/134512 Commit-Queue: Mike Klein <mtklein@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com> Auto-Submit: Mike Klein <mtklein@chromium.org> Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'include/private')
-rw-r--r--include/private/SkTFitsIn.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/private/SkTFitsIn.h b/include/private/SkTFitsIn.h
index 9dcfdf3384..5fdf74383a 100644
--- a/include/private/SkTFitsIn.h
+++ b/include/private/SkTFitsIn.h
@@ -8,7 +8,6 @@
#ifndef SkTFitsIn_DEFINED
#define SkTFitsIn_DEFINED
-#include <cassert>
#include <limits>
#include <type_traits>
@@ -53,10 +52,12 @@
*/
template <typename D, typename S>
-static constexpr inline bool SkTFitsIn(S src) {
+static constexpr inline
+typename std::enable_if<(std::is_integral<S>::value || std::is_enum<S>::value) &&
+ (std::is_integral<D>::value || std::is_enum<D>::value), bool>::type
+/*bool*/ SkTFitsIn(S src) {
// SkTFitsIn() is used in public headers, so needs to be written targeting at most C++11.
- return assert(std::is_integral<S>::value || std::is_enum<S>::value),
- assert(std::is_integral<D>::value || std::is_enum<D>::value),
+ return
// E.g. (int8_t)(uint8_t) int8_t(-1) == -1, but the uint8_t == 255, not -1.
(std::is_signed<S>::value && std::is_unsigned<D>::value && sizeof(S) <= sizeof(D)) ?