OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkConstexprMath_DEFINED | 8 #ifndef SkConstexprMath_DEFINED |
9 #define SkConstexprMath_DEFINED | 9 #define SkConstexprMath_DEFINED |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 if the bits of type t are considered as unsigned base two. | 39 if the bits of type t are considered as unsigned base two. |
40 */ | 40 */ |
41 #define SK_BASE_N_DIGITS_IN(n, t) (\ | 41 #define SK_BASE_N_DIGITS_IN(n, t) (\ |
42 SK_LOG<SK_2N1<(sizeof(t) * CHAR_BIT)>::value, n>::value\ | 42 SK_LOG<SK_2N1<(sizeof(t) * CHAR_BIT)>::value, n>::value\ |
43 ) | 43 ) |
44 /** Compile-time constant number of base 10 digits in type t | 44 /** Compile-time constant number of base 10 digits in type t |
45 if the bits of type t are considered as unsigned base two. | 45 if the bits of type t are considered as unsigned base two. |
46 */ | 46 */ |
47 #define SK_DIGITS_IN(t) SK_BASE_N_DIGITS_IN(10, (t)) | 47 #define SK_DIGITS_IN(t) SK_BASE_N_DIGITS_IN(10, (t)) |
48 | 48 |
49 //! a > b ? a : b | 49 // Compile-time constant maximum value of two unsigned values. |
50 #define SK_MAX(a,b) (((a) > (b)) ? (a) : (b)) | 50 template <uintmax_t a, uintmax_t b> struct SkTUMax { |
| 51 static const uintmax_t value = (b < a) ? a : b; |
| 52 }; |
51 | 53 |
52 #endif | 54 #endif |
OLD | NEW |