10#define MI_BASE_TYPES_H
18#if defined(__has_include)
19#if (!defined(_WIN32) || (defined(_HAS_CXX20) && _HAS_CXX20) || _MSVC_LANG >= 202002L)
20#if __has_include(<bit>)
54#if defined(MI_COMPILER_MSC)
56typedef signed __int64
Sint64;
57typedef unsigned __int64
Uint64;
59#elif defined(MI_COMPILER_GCC)
66typedef signed long long Sint64;
67typedef unsigned long long Uint64;
89#define MI_BASE_FMT_MI_SINT64 "lld"
91#define MI_BASE_FMT_MI_SINT64 "d"
101#define MI_BASE_FMT_MI_UINT64 "llu"
103#define MI_BASE_FMT_MI_UINT64 "u"
172#define MI_BASE_FMT_MI_SIZE "llu"
174#define MI_BASE_FMT_MI_SIZE "u"
184#define MI_BASE_FMT_MI_DIFFERENCE "lld"
186#define MI_BASE_FMT_MI_DIFFERENCE "d"
192#define MI_PI 3.14159265358979323846
194#define MI_PI_2 1.57079632679489661923
196#define MI_PI_4 0.78539816339744830962
240 if (lhs < rhs)
return LESS;
241 else if (rhs < lhs)
return GREATER;
253{
return a < b ? a : b; }
257{
return a > b ? a : b; }
269{
return a < b ? a : b; }
271{
return a < b ? a : b; }
273{
return a < b ? a : b; }
275{
return a < b ? a : b; }
277{
return a < b ? a : b; }
279{
return a < b ? a : b; }
281{
return a < b ? a : b; }
283{
return a < b ? a : b; }
285{
return a < b ? a : b; }
287{
return a < b ? a : b; }
290{
return a > b ? a : b; }
292{
return a > b ? a : b; }
294{
return a > b ? a : b; }
296{
return a > b ? a : b; }
298{
return a > b ? a : b; }
300{
return a > b ? a : b; }
302{
return a > b ? a : b; }
304{
return a > b ? a : b; }
306{
return a > b ? a : b; }
308{
return a > b ? a : b; }
323 template <
class Target,
class Source>
336#ifdef __cpp_lib_bit_cast
337template<
class T,
class S>
338constexpr T
binary_cast(
const S& src)
noexcept {
return std::bit_cast<T,S>(src); }
340template <
class Target,
class Source>
344 Binary_cast<Target, Source> val_;
388 static T (
min)()
throw() {
return T(); }
396 static T (
max)()
throw() {
return T(); }
463 static Sint32 (
min)()
throw() {
return -2147483647 - 1; }
472 static Sint64 (
min)()
throw() {
return -9223372036854775807LL - 1LL; }
473 static Sint64 (
max)()
throw() {
return 9223372036854775807LL; }
502 static Uint64 (
max)()
throw() {
return 18446744073709551615ULL; }
506#ifdef MI_ARCH_BIG_ENDIAN
507# define MI__FLOAT32_INF_REP { 0x7f80, 0 }
508# define MI__FLOAT32_QNAN_REP { 0x7fc1, 0 }
509# define MI__FLOAT32_SNAN_REP { 0x7f81, 0 }
510# define MI__FLOAT64_INF_REP { 0x7ff0, 0, 0, 0 }
511# define MI__FLOAT64_QNAN_REP { 0x7ff9, 0, 0, 0 }
512# define MI__FLOAT64_SNAN_REP { 0x7ff1, 0, 0, 0 }
514#ifdef MI_ARCH_LITTLE_ENDIAN
515# define MI__FLOAT32_INF_REP { 0, 0x7f80 }
516# define MI__FLOAT32_QNAN_REP { 0, 0x7fc0 }
517# define MI__FLOAT32_SNAN_REP { 0, 0x7fa0 }
518# define MI__FLOAT64_INF_REP { 0, 0, 0, 0x7ff0 }
519# define MI__FLOAT64_QNAN_REP { 0, 0, 0, 0x7ff8 }
520# define MI__FLOAT64_SNAN_REP { 0, 0, 0, 0x7ff4 }
540 Float32_rep rep = {
MI__FLOAT32_INF_REP };
544 Float32_rep rep = {
MI__FLOAT32_QNAN_REP };
548 Float32_rep rep = {
MI__FLOAT32_SNAN_REP };
560 static Float64 (
min)()
throw() {
return 2.2250738585072014e-308; }
561 static Float64 (
max)()
throw() {
return 1.7976931348623158e+308; }
564 Float64_rep rep = {
MI__FLOAT64_INF_REP };
568 Float64_rep rep = {
MI__FLOAT64_QNAN_REP };
572 Float64_rep rep = {
MI__FLOAT64_SNAN_REP };
Assertions and compile-time assertions.
Configuration of the Base API.
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:65
#define MI_PREVENT_MACRO_EXPAND
Empty macro that can be used after function names to prevent macro expansion that happen to have the ...
Definition: config.h:97
static Sint16 negative_max()
SHRT_MIN.
Definition: types.h:456
static T signaling_NaN()
Returns a signaling NaN value for T, if one exists, and T() otherwise.
Definition: types.h:413
static T quiet_NaN()
Returns a quiet NaN value for T, if one exists, and T() otherwise.
Definition: types.h:410
static Float32 negative_max()
-FLT_MAX
Definition: types.h:538
static Sint8 negative_max()
SCHAR_MIN.
Definition: types.h:447
static const bool has_signaling_NaN
Constant that is true if and only if T has a signaling NaN (not-a-number) representation.
Definition: types.h:378
static const bool has_quiet_NaN
Constant that is true if and only if T has a quiet NaN (not-a-number) representation.
Definition: types.h:372
static Float64 negative_max()
-DBL_MAX
Definition: types.h:562
static Sint32 negative_max()
INT_MIN.
Definition: types.h:465
static T infinity()
Returns an infinity value for T, if one exists, and T() otherwise.
Definition: types.h:407
static const bool has_infinity
Constant that is true if and only if T has an infinity representation.
Definition: types.h:367
static Sint64 negative_max()
LLONG_MIN.
Definition: types.h:474
static const bool is_specialized
Constant that is true if and only if this traits is specialized for T.
Definition: types.h:362
static T() max()
Returns the maximum finite value for T.
Definition: types.h:396
static T() min()
Returns the minimum finite value for T (and for floating point types the minimum positive value).
Definition: types.h:388
static T negative_max()
Returns the smallest finite negative value for T.
Definition: types.h:404
long long Sint64
64-bit signed integer.
Definition: types.h:61
unsigned long long Uint64
64-bit unsigned integer.
Definition: types.h:62
signed short Sint16
16-bit signed integer.
Definition: types.h:45
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
static const Difference DIFFERENCE_MIN_VALUE
The minimum value for Difference.
Definition: types.h:150
Target binary_cast(Source const &val)
Cast an immutable 'Source' value to an immutable 'Target' value.
Definition: types.h:341
unsigned char Uint8
8-bit unsigned integer.
Definition: types.h:47
static const Size SIZE_MAX_VALUE
The maximum value for Size.
Definition: types.h:140
Comparison_result three_valued_sign(T t)
Returns the three valued sign for a numerical type T.
Definition: types.h:225
Sint64 Difference
Signed integral type that is large enough to hold the difference of two pointers.
Definition: types.h:122
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
Comparison_result operator-(Comparison_result sign)
Reverses the sign of a three valued enum.
Definition: types.h:214
signed char Sint8
8-bit signed integer.
Definition: types.h:44
Comparison_result
An enum for a three-valued comparison result.
Definition: types.h:203
double Float64
64-bit float.
Definition: types.h:52
float Float32
32-bit float.
Definition: types.h:51
unsigned short Uint16
16-bit unsigned integer.
Definition: types.h:48
Comparison_result three_valued_compare(T lhs, T rhs)
Returns the three valued comparison result between two values of a numerical type T.
Definition: types.h:238
static const Difference DIFFERENCE_MAX_VALUE
The maximum value for Difference.
Definition: types.h:160
signed int Sint32
32-bit signed integer.
Definition: types.h:46
@ POSITIVE
= +1. Sign of a value is positive.
Definition: types.h:206
@ GREATER
= +1. First value is greater than second value.
Definition: types.h:210
@ EQUAL
= 0. First value is equal to second value.
Definition: types.h:209
@ NEGATIVE
= -1. Sign of a value is negative.
Definition: types.h:204
@ LESS
= -1. First value is less than second value.
Definition: types.h:208
@ ZERO
= 0. Value is zero.
Definition: types.h:205
Color abs(const Color &c)
Returns a color with the elementwise absolute values of the color c.
Definition: color.h:474
Color sign(const Color &c)
Returns the elementwise sign of color c.
Definition: color.h:758
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: math.h:22
Base class for the helper class to deduce properties of numeric types defined in this API.
Definition: types.h:360
Helper class to deduce properties of numeric types defined in this API.
Definition: types.h:428