Index: include/core/SkTemplates.h |
=================================================================== |
--- include/core/SkTemplates.h (revision 13776) |
+++ include/core/SkTemplates.h (working copy) |
@@ -11,6 +11,8 @@ |
#define SkTemplates_DEFINED |
#include "SkTypes.h" |
+#include <climits> |
+#include <limits> |
#include <new> |
/** \file SkTemplates.h |
@@ -64,6 +66,15 @@ |
); |
} |
+/** SkTSetBit<N, T>::value is a T with the Nth bit set. */ |
+template<unsigned N, typename T = uintmax_t> struct SkTSetBit { |
+ static const T value = static_cast<T>(1) << N; |
+ SK_COMPILE_ASSERT(sizeof(T)*CHAR_BIT > N, SkTSetBit_N_too_large); |
+ SK_COMPILE_ASSERT(std::numeric_limits<T>::is_integer, SkTSetBit_T_must_be_integer); |
+ SK_COMPILE_ASSERT(!std::numeric_limits<T>::is_signed, SkTSetBit_T_must_be_unsigned); |
+ SK_COMPILE_ASSERT(std::numeric_limits<T>::radix == 2, SkTSetBit_T_radix_must_be_2); |
+}; |
+ |
/** \class SkAutoTCallVProc |
Call a function when this goes out of scope. The template uses two |