#if defined(__cplusplus)
#pragma once
#ifndef _XTGMATH
#define _XTGMATH
#ifndef RC_INVOKED
#include <cstdlib>
#include <xtr1common>
#include <yvals.h>
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,_STL_WARNING_LEVEL)
#pragma warning(disable: _STL_DISABLED_WARNINGS)
#pragma warning(disable:
4455
4494
4619
4643
4702
4984
4988
)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
template
<
class
,
class
>
using
=
<
<
,
long
double
> ||
<
,
long
double
>,
long
double
,
<
<
,
float
> &&
<
,
float
>,
float
,
double
>>;
#define _CRTDEFAULT
#define _CRTSPECIAL _ACRTIMP
#define _GENERIC_MATH1R(FUN, RET, CRTTYPE) \
extern "C" _Check_return_ CRTTYPE RET __cdecl FUN(_In_ double); \
template<class _Ty, \
class = _STD enable_if_t<_STD is_integral_v<_Ty>>> _NODISCARD inline \
RET FUN(_Ty _Left) \
{ \
return (_CSTD FUN(static_cast<double>(_Left))); \
}
#define _GENERIC_MATH1(FUN, CRTTYPE) \
_GENERIC_MATH1R(FUN, double, CRTTYPE)
#define _GENERIC_MATH1X(FUN, ARG2, CRTTYPE) \
extern "C" _Check_return_ CRTTYPE double __cdecl FUN(_In_ double, ARG2); \
template<class _Ty, \
class = _STD enable_if_t<_STD is_integral_v<_Ty>>> _NODISCARD inline \
double FUN(_Ty _Left, ARG2 _Arg2) \
{ \
return (_CSTD FUN(static_cast<double>(_Left), _Arg2)); \
}
#define _GENERIC_MATH2_CALL(FUN, CRTTYPE, CALL_OPT) \
extern "C" _Check_return_ CRTTYPE double CALL_OPT FUN(_In_ double, _In_ double); \
template<class _Ty1, \
class _Ty2, \
class = _STD enable_if_t<_STD is_arithmetic_v<_Ty1> && _STD is_arithmetic_v<_Ty2>>> _NODISCARD inline \
_STD _Common_float_type_t<_Ty1, _Ty2> FUN(_Ty1 _Left, _Ty2 _Right) \
{ \
using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>; \
return (_CSTD FUN(static_cast<_Common>(_Left), static_cast<_Common>(_Right))); \
}
#define _GENERIC_MATH2(FUN, CRTTYPE) \
_GENERIC_MATH2_CALL(FUN, CRTTYPE, __cdecl)
template
<
class
,
class
,
class = _STD enable_if_t<_STD is_arithmetic_v<_Ty1> && _STD is_arithmetic_v<_Ty2>>> _NODISCARD inline
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
_STD _Common_float_type_t<_Ty1, _Ty2> pow(const _Ty1 _Left, const _Ty2 _Right)
::
std
::
<
,
>
(
const
,
const
)
{
using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>;
return (_CSTD pow(static_cast<_Common>(_Left), static_cast<_Common>(_Right)));
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
)));
}
_GENERIC_MATH1(acos, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(asin, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(atan, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH2(atan2, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH1(ceil, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(cos, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(cosh, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(exp, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(fabs, _CRT_JIT_INTRINSIC)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(floor, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH2(fmod, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH1X(frexp, _Out_ int *, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
int
*);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
,
int
*
) {
return
(::
(
static_cast
<
double
>(
),
)); }
_GENERIC_MATH1X(ldexp, _In_ int, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
int
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
,
int
) {
return
(::
(
static_cast
<
double
>(
),
)); }
_GENERIC_MATH1(log, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(log10, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(sin, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(sinh, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(sqrt, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(tan, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(tanh, _CRTDEFAULT)
extern
"C"
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
#if !_HAS_IF_CONSTEXPR
inline
float
(
float
,
float
,
float
)
{
return (_CSTD fmaf(_Left, _Middle, _Right));
}
inline
double
(
double
,
double
,
double
)
{
return (_CSTD fma(_Left, _Middle, _Right));
}
inline
long
double
(
long
double
,
long
double
,
long
double
)
{
return (_CSTD fmal(_Left, _Middle, _Right));
}
#endif /* ^^^ original code ^^^ */
template
<
class
,
class
,
class
,
class = _STD enable_if_t<_STD is_arithmetic_v<_Ty1> && _STD is_arithmetic_v<_Ty2>
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>
&& _STD is_arithmetic_v<_Ty3>>> _NODISCARD inline
_STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>>
(
,
,
)
{
using _Common = _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>>;
using
= ::
std
::
<
, ::
std
::
<
,
>>;
#if _HAS_IF_CONSTEXPR
if constexpr (_STD is_same_v<_Common, float>)
{
return (_CSTD fmaf(static_cast<_Common>(_Left), static_cast<_Common>(_Middle), static_cast<_Common>(_Right)));
}
else if constexpr (_STD is_same_v<_Common, double>)
{
return (_CSTD fma(static_cast<_Common>(_Left), static_cast<_Common>(_Middle), static_cast<_Common>(_Right)));
}
else
{
return (_CSTD fmal(static_cast<_Common>(_Left), static_cast<_Common>(_Middle), static_cast<_Common>(_Right)));
}
#else /* vvv original code vvv */
return
(
(
static_cast
<
>(
),
static_cast
<
>(
),
static_cast
<
>(
)));
#endif /* ^^^ original code ^^^ */
}
#if !_HAS_IF_CONSTEXPR
inline
float
(
float
,
float
,
int
*
)
{
return (_CSTD remquof(_Left, _Right, _Pquo));
}
inline
double
(
double
,
double
,
int
*
)
{
return (_CSTD remquo(_Left, _Right, _Pquo));
}
inline
long
double
(
long
double
,
long
double
,
int
*
)
{
return (_CSTD remquol(_Left, _Right, _Pquo));
}
#endif /* ^^^ original code ^^^ */
template
<
class
,
class
,
class = _STD enable_if_t<_STD is_arithmetic_v<_Ty1> && _STD is_arithmetic_v<_Ty2>>> inline
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
_STD _Common_float_type_t<_Ty1, _Ty2>
(
,
,
int
*
)
{
using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>;
#if _HAS_IF_CONSTEXPR
if constexpr (_STD is_same_v<_Common, float>)
{
return (_CSTD remquof(static_cast<_Common>(_Left), static_cast<_Common>(_Right), _Pquo));
}
else if constexpr (_STD is_same_v<_Common, double>)
{
return (_CSTD remquo(static_cast<_Common>(_Left), static_cast<_Common>(_Right), _Pquo));
}
else
{
return (_CSTD remquol(static_cast<_Common>(_Left), static_cast<_Common>(_Right), _Pquo));
}
#else /* vvv original code vvv */
return
(
(
static_cast
<
>(
),
static_cast
<
>(
),
));
#endif /* ^^^ original code ^^^ */
}
_GENERIC_MATH1(acosh, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(asinh, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(atanh, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(cbrt, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH2(copysign, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH1(erf, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(erfc, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(expm1, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(exp2, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH2(fdim, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH2(fmax, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH2(fmin, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH2(hypot, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH1R(ilogb, int, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
int
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
int
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(lgamma, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1R(llrint, long long, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
long
long
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
long
long
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1R(llround, long long, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
long
long
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
long
long
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(log1p, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(log2, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(logb, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1R(lrint, long, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
long
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
long
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1R(lround, long, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
long
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
long
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(nearbyint, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH2(nextafter, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH1X(nexttoward, _In_ long double, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
long
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
,
long
double
) {
return
(::
(
static_cast
<
double
>(
),
)); }
_GENERIC_MATH2(remainder, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
double
);
template
<
class
,
class
,
class
= ::
std
::
<::
std
::
<
> && ::
std
::
<
>>>
inline
::
std
::
<
,
>
(
,
) {
using
= ::
std
::
<
,
>;
return
(::
(
static_cast
<
>(
),
static_cast
<
>(
))); }
_GENERIC_MATH1(rint, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(round, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1X(scalbln, _In_ long, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
long
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
,
long
) {
return
(::
(
static_cast
<
double
>(
),
)); }
_GENERIC_MATH1X(scalbn, _In_ int, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
,
int
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
,
int
) {
return
(::
(
static_cast
<
double
>(
),
)); }
_GENERIC_MATH1(tgamma, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
_GENERIC_MATH1(trunc, _CRTSPECIAL)
extern
"C"
__declspec
(dllimport)
double
__cdecl
(
double
);
template
<
class
,
class
= ::
std
::
<::
std
::
<
>>>
inline
double
(
) {
return
(::
(
static_cast
<
double
>(
))); }
#undef _CRTDEFAULT
#undef _CRTSPECIAL
#undef _GENERIC_MATH1R
#undef _GENERIC_MATH1
#undef _GENERIC_MATH1X
#undef _GENERIC_MATH2_CALL
#undef _GENERIC_MATH2
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _XTGMATH */
#endif /* defined(__cplusplus) */
#pragma pack(pop)