aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
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-14 14:51:07 +0000
commit4d4665436e540bd2ca393c139cbaff1eabd62ee2 (patch)
treead86ee83c09448ce88b416f46a5fa538edd2af74 /include
parent2c8bc68a41e6ecf97679116f063ae63aa93f7b89 (diff)
Reland "use std::enable_if instead of assert()"
This is a reland of c6530d1e5ecce640e0255d66a01f9db73add7df9 Original change's description: > 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> Change-Id: I50849c89a37255396706ce659e20f00c0b0f08c6 Reviewed-on: https://skia-review.googlesource.com/134860 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'include')
-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)) ?