5#include <system/boolean.h>
6#include <system/byte.h>
7#include <system/double.h>
8#include <system/int16.h>
9#include <system/int32.h>
10#include <system/int64.h>
11#include <system/sbyte.h>
12#include <system/single.h>
13#include <system/uint16.h>
14#include <system/uint32.h>
15#include <system/uint64.h>
17#include <system/exceptions.h>
18#include <system/get_hash_code.h>
28struct IsSigned : std::is_signed<T> {};
31struct IsUnsigned : std::is_unsigned<T> {};
34struct IsSigned<
Decimal> : std::true_type {};
37struct IsUnsigned<
Decimal> : std::false_type {};
39template<
typename TTo,
typename TFrom>
40typename std::enable_if<IsSigned<TFrom>::value && IsSigned<TTo>::value>::type CheckCast(TFrom value)
42 if (value < std::numeric_limits<TTo>::min() || value > std::numeric_limits<TTo>::max())
43 throw OverflowException();
46template<
typename TTo,
typename TFrom>
47typename std::enable_if<IsSigned<TFrom>::value && IsUnsigned<TTo>::value>::type CheckCast(TFrom value)
49 if (value < 0 || std::numeric_limits<TTo>::max() - value < 0)
50 throw OverflowException();
53template<
typename TTo,
typename TFrom>
54typename std::enable_if<IsUnsigned<TFrom>::value && IsSigned<TTo>::value>::type CheckCast(TFrom value)
56 if (
static_cast<TTo
>(std::numeric_limits<TTo>::max() - value) < 0)
57 throw OverflowException();
60template<
typename TTo,
typename TFrom>
61typename std::enable_if<IsUnsigned<TFrom>::value && IsUnsigned<TTo>::value>::type CheckCast(TFrom value)
63 if (value > std::numeric_limits<TTo>::max())
64 throw OverflowException();
76template <
typename TA,
typename TB>
77inline bool Equals(
const TA& a,
const TB& b)
92 return (std::isnan(a) && std::isnan(b)) ? true : a == b;
102 return (std::isnan(a) && std::isnan(b)) ? true : a == b;
111template <
typename TA,
typename TB>
112std::enable_if_t<!std::is_floating_point<TA>::value && !std::is_floating_point<TB>::value,
int>
115 return (a < b) ? -1 : ((b < a) ? 1 : 0);
124template <
typename TA,
typename TB>
125std::enable_if_t<std::is_floating_point<TA>::value && std::is_floating_point<TB>::value,
int>
136 return (a < b) ? -1 : ((b < a) ? 1 : 0);
146 return std::isnan(value);
156 return std::isinf(value);
166 return (std::isinf(value) && value > 0);
176 return (std::isinf(value) && value < 0);
185template<
typename TTo,
typename TFrom>
188 Details::CheckCast<TTo>(value);
189 return static_cast<TTo
>(value);
Definition: db_command.h:9
std::enable_if_t<!std::is_floating_point< TA >::value &&!std::is_floating_point< TB >::value, int > Compare(const TA &a, const TB &b)
Compares two values.
Definition: primitive_types.h:113
bool Equals(const TA &a, const TB &b)
Determines the equality of two values applying operator==() to them.
Definition: primitive_types.h:77
bool IsNegativeInfinity(const T &value)
Determines if the specified value represents negative infinity.
Definition: primitive_types.h:174
@ Decimal
A simple type representing values ranging from 1.0 x 10 -28 to approximately 7.9 x 10 28 with 28-29 s...
TTo CheckedCast(TFrom value)
Determines if the specified value falls into the range of values of type TTo and if it does casts it ...
Definition: primitive_types.h:186
bool Equals< float, float >(const float &a, const float &b)
Specialization for single-precision floating point values. Although two floating point NaNs are defin...
Definition: primitive_types.h:90
bool Equals< double, double >(const double &a, const double &b)
Specialization for double-precision floating point values.
Definition: primitive_types.h:100
bool IsPositiveInfinity(const T &value)
Determines if the specified value represents positive infinity.
Definition: primitive_types.h:164
bool IsInfinity(const T &value)
Determines if the specified value represents infinity.
Definition: primitive_types.h:154
bool IsNaN(const T &value)
Determines if the specified value is Not-A-Number value.
Definition: primitive_types.h:144