File Index Symbol Index

/* xtgmath.h internal header */
#if defined(__cplusplus)
#pragma once
#ifndef _XTGMATH
#define _XTGMATH
#ifndef RC_INVOKED
#include <cstdlib>
#include <xtr1common>
#include <yvals.h>
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
template
<
class
_Ty1
,
class
_Ty2
>
using
_Common_float_type_t
=
conditional_t
<
is_same_v
<
_Ty1
,
long
double
> ||
is_same_v
<
_Ty2
,
long
double
>,
long
double
,
conditional_t
<
is_same_v
<
_Ty1
,
float
> &&
is_same_v
<
_Ty2
,
float
>,
float
,
double
>>;
// find type for two-argument math function
#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
_Ty1
,
class
_Ty2
, {
// bring mixed types to a common type
}
//_GENERIC_MATH1(abs, _CRTDEFAULT) // has integer overloads
//_GENERIC_MATH1(modf, _CRTDEFAULT) // types must match
//_GENERIC_MATH2(pow, _CRTDEFAULT) // hand crafted
// C99 MATH FUNCTIONS
// FUNCTION TEMPLATE fma
#if !_HAS_IF_CONSTEXPR
inline
float
_Fma
(
float
_Left
,
float
_Middle
,
float
_Right
) {
// call float fma
}
inline
double
_Fma
(
double
_Left
,
double
_Middle
,
double
_Right
) {
// call double fma
}
inline
long
double
_Fma
(
long
double
_Left
,
long
double
_Middle
,
long
double
_Right
) {
// call long double fma
}
#endif /* ^^^ original code ^^^ */
template
<
class
_Ty1
,
class
_Ty2
,
class
_Ty3
,
fma
(
_Ty1
_Left
,
_Ty2
_Middle
,
_Ty3
_Right
) {
// bring mixed types to a common type
#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
(
_Fma
(
static_cast
<
_Common
>(
_Left
),
static_cast
<
_Common
>(
_Middle
),
static_cast
<
_Common
>(
_Right
)));
#endif /* ^^^ original code ^^^ */
}
// FUNCTION TEMPLATE remquo
#if !_HAS_IF_CONSTEXPR
inline
float
_Remquo
(
float
_Left
,
float
_Right
,
int
*
_Pquo
) {
// call float remquo
}
inline
double
_Remquo
(
double
_Left
,
double
_Right
,
int
*
_Pquo
) {
// call double remquo
}
inline
long
double
_Remquo
(
long
double
_Left
,
long
double
_Right
,
int
*
_Pquo
) {
// call long double remquo
}
#endif /* ^^^ original code ^^^ */
template
<
class
_Ty1
,
class
_Ty2
,
remquo
(
_Ty1
_Left
,
_Ty2
_Right
,
int
*
_Pquo
) {
// bring mixed types to a common type
#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
(
_Remquo
(
static_cast
<
_Common
>(
_Left
),
static_cast
<
_Common
>(
_Right
),
_Pquo
));
#endif /* ^^^ original code ^^^ */
}
//_GENERIC_MATH3(fma, _CRTSPECIAL) // hand crafted
//_GENERIC_MATH2X(remquo, _CRTSPECIAL) // hand crafted
#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
/* * Copyright (c) by P.J. Plauger. All rights reserved. * Consult your license regarding permissions and restrictions. V6.50:0009 */