Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ResolveTypeAmbiguity.h File Reference
+ Include dependency graph for ResolveTypeAmbiguity.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MIX_SIGNED_INTS_2_ARGS_ACTUAL(Func, OptionalMarkup)
 
#define MIX_SIGNED_INTS_2_ARGS(Func)   MIX_SIGNED_INTS_2_ARGS_ACTUAL(Func,)
 
#define MIX_SIGNED_INTS_2_ARGS_CONSTEXPR(Func)   MIX_SIGNED_INTS_2_ARGS_ACTUAL(Func, CONSTEXPR)
 
#define MIX_SIGNED_TYPES_3_ARGS_ACTUAL(Func, OptionalMarkup)
 
#define MIX_SIGNED_INTS_3_ARGS(Func)   MIX_SIGNED_INTS_3_ARGS_ACTUAL(Func,)
 
#define MIX_SIGNED_INTS_3_ARGS_CONSTEXPR(Func)   MIX_SIGNED_INTS_3_ARGS_ACTUAL(Func, CONSTEXPR)
 
#define MIX_FLOATS_2_ARGS(Func)
 
#define MIX_FLOATS_3_ARGS(Func)
 
#define RESOLVE_FLOAT_AMBIGUITY_2_ARGS(Func)    MIX_FLOATS_2_ARGS(Func);
 
#define RESOLVE_FLOAT_AMBIGUITY_3_ARGS(Func)    MIX_FLOATS_3_ARGS(Func);
 
#define MIX_FLOATS_TO_TYPE_2_ARGS(Func, ReturnType)
 
#define MIX_FLOATS_TO_TYPE_3_ARGS(Func, ReturnType)
 
#define RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_2_ARGS(Func, ReturnType)    MIX_FLOATS_TO_TYPE_2_ARGS(Func, ReturnType);
 
#define RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_3_ARGS(Func, ReturnType)    MIX_FLOATS_TO_TYPE_3_ARGS(Func, ReturnType);
 
#define RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS(Func)   RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_2_ARGS(Func, bool)
 
#define RESOLVE_FLOAT_PREDICATE_AMBIGUITY_3_ARGS(Func)   RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_3_ARGS(Func, bool)
 

Macro Definition Documentation

◆ MIX_FLOATS_2_ARGS

#define MIX_FLOATS_2_ARGS ( Func)
Value:
template < \
typename Arg1, \
typename Arg2 \
UE_CONSTRAINT((std::is_floating_point_v<Arg1> || std::is_floating_point_v<Arg2>) && !std::is_same_v<Arg1, Arg2>) \
> \
static FORCEINLINE auto Func(Arg1 X, Arg2 Y) -> decltype(X * Y) \
{ \
using ArgType = decltype(X * Y); \
return Func((ArgType)X, (ArgType)Y); \
}
#define FORCEINLINE
Definition Platform.h:644
#define UE_CONSTRAINTS_END

Definition at line 89 of file ResolveTypeAmbiguity.h.

◆ MIX_FLOATS_3_ARGS

#define MIX_FLOATS_3_ARGS ( Func)
Value:
template < \
typename Arg1, \
typename Arg2, \
typename Arg3 \
(std::is_floating_point_v<Arg1> || std::is_floating_point_v<Arg2> || std::is_floating_point_v<Arg3>) && \
(!std::is_same_v<Arg1, Arg2> || !std::is_same_v<Arg2, Arg3> || !std::is_same_v<Arg1, Arg3>) \
) \
> \
static FORCEINLINE auto Func(Arg1 X, Arg2 Y, Arg3 Z) -> decltype(X * Y * Z) \
{ \
using ArgType = decltype(X * Y * Z); \
return Func((ArgType)X, (ArgType)Y, (ArgType)Z); \
}

Definition at line 104 of file ResolveTypeAmbiguity.h.

◆ MIX_FLOATS_TO_TYPE_2_ARGS

#define MIX_FLOATS_TO_TYPE_2_ARGS ( Func,
ReturnType )
Value:
template < \
typename Arg1, \
typename Arg2 \
(std::is_floating_point_v<Arg1> || std::is_floating_point_v<Arg2>) && \
!std::is_same_v<Arg1, Arg2> \
) \
> \
static FORCEINLINE ReturnType Func(Arg1 X, Arg2 Y) \
{ \
using ArgType = decltype(X * Y); \
return Func((ArgType)X, (ArgType)Y); \
}

Definition at line 136 of file ResolveTypeAmbiguity.h.

◆ MIX_FLOATS_TO_TYPE_3_ARGS

#define MIX_FLOATS_TO_TYPE_3_ARGS ( Func,
ReturnType )
Value:
template < \
typename Arg1, \
typename Arg2, \
typename Arg3 \
(std::is_floating_point_v<Arg1> || std::is_floating_point_v<Arg2> || std::is_floating_point_v<Arg3>) && \
(!std::is_same_v<Arg1, Arg2> || !std::is_same_v<Arg1, Arg3> || !std::is_same_v<Arg2, Arg3>) \
) \
> \
static FORCEINLINE ReturnType Func(Arg1 X, Arg2 Y, Arg3 Z) \
{ \
using ArgType = decltype(X * Y * Z); \
return Func((ArgType)X, (ArgType)Y, (ArgType)Z); \
}

Definition at line 154 of file ResolveTypeAmbiguity.h.

◆ MIX_SIGNED_INTS_2_ARGS

#define MIX_SIGNED_INTS_2_ARGS ( Func)    MIX_SIGNED_INTS_2_ARGS_ACTUAL(Func,)

Definition at line 56 of file ResolveTypeAmbiguity.h.

◆ MIX_SIGNED_INTS_2_ARGS_ACTUAL

#define MIX_SIGNED_INTS_2_ARGS_ACTUAL ( Func,
OptionalMarkup )
Value:
template < \
typename Arg1, \
typename Arg2 \
!std::is_same_v<Arg1, Arg2> && \
std::is_signed_v<Arg1> && std::is_integral_v<Arg1> && \
std::is_signed_v<Arg2> && std::is_integral_v<Arg2> \
) \
> \
static OptionalMarkup FORCEINLINE auto Func(Arg1 X, Arg2 Y) -> decltype(X * Y) \
{ \
using ArgType = decltype(X * Y); \
return Func((ArgType)X, (ArgType)Y); \
}

This file defines a few macros which can be used to restrict (via deprecation) ambiguous calls to functions expecting float params/return type. This also handles mixing of argument types where at least one argument is a float/double and the rest can be promoted to the highest-precision type to infer the expected type of the return value, or where non-float arguments are mixed in a function where the result should be the result of mixed arithmetic between the types.

For example:

template< class T > static T MyFunc(const T X, const T Y) { return X < Y ? X : Y; } // Allows mixing of types without causing type ambiguity MIX_TYPES_2_ARGS(MyFunc);

static float Sin( float Value ) { return sinf(Value); } static double Sin( double Value ) { return sin(Value); }

static float Fmod(float X, float Y); static double Fmod(double X, double Y); // Disallows Fmod(int32, int32) because one argument must be a floating point type. // Promotes calls such as "Fmod(float, double)" or "Fmod(double, int)" to "double Fmod(double, double)" because double has the highest precision of the argument types. RESOLVE_FLOAT_AMBIGUITY_2_ARGS(Fmod);

Definition at line 38 of file ResolveTypeAmbiguity.h.

◆ MIX_SIGNED_INTS_2_ARGS_CONSTEXPR

#define MIX_SIGNED_INTS_2_ARGS_CONSTEXPR ( Func)    MIX_SIGNED_INTS_2_ARGS_ACTUAL(Func, CONSTEXPR)

Definition at line 57 of file ResolveTypeAmbiguity.h.

◆ MIX_SIGNED_INTS_3_ARGS

#define MIX_SIGNED_INTS_3_ARGS ( Func)    MIX_SIGNED_INTS_3_ARGS_ACTUAL(Func,)

Definition at line 84 of file ResolveTypeAmbiguity.h.

◆ MIX_SIGNED_INTS_3_ARGS_CONSTEXPR

#define MIX_SIGNED_INTS_3_ARGS_CONSTEXPR ( Func)    MIX_SIGNED_INTS_3_ARGS_ACTUAL(Func, CONSTEXPR)

Definition at line 85 of file ResolveTypeAmbiguity.h.

◆ MIX_SIGNED_TYPES_3_ARGS_ACTUAL

#define MIX_SIGNED_TYPES_3_ARGS_ACTUAL ( Func,
OptionalMarkup )
Value:
template < \
typename Arg1, \
typename Arg2, \
typename Arg3 \
( \
!std::is_same_v<Arg1, Arg2>> || \
!std::is_same_v<Arg2, Arg3>> || \
!std::is_same_v<Arg1, Arg3>> \
) && \
std::is_signed_v<Arg1> && std::is_integral_v<Arg1> && \
std::is_signed_v<Arg2> && std::is_integral_v<Arg2> && \
std::is_signed_v<Arg3> && std::is_integral_v<Arg3> \
) \
> \
static OptionalMarkup FORCEINLINE auto Func(Arg1 X, Arg2 Y, Arg3 Z) -> decltype(X * Y * Z) \
{ \
using ArgType = decltype(X * Y * Z); \
return Func((ArgType)X, (ArgType)Y, (ArgType)Z); \
}

Definition at line 60 of file ResolveTypeAmbiguity.h.

◆ RESOLVE_FLOAT_AMBIGUITY_2_ARGS

#define RESOLVE_FLOAT_AMBIGUITY_2_ARGS ( Func)     MIX_FLOATS_2_ARGS(Func);

Definition at line 126 of file ResolveTypeAmbiguity.h.

◆ RESOLVE_FLOAT_AMBIGUITY_3_ARGS

#define RESOLVE_FLOAT_AMBIGUITY_3_ARGS ( Func)     MIX_FLOATS_3_ARGS(Func);

Definition at line 129 of file ResolveTypeAmbiguity.h.

◆ RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS

#define RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS ( Func)    RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_2_ARGS(Func, bool)

Definition at line 183 of file ResolveTypeAmbiguity.h.

◆ RESOLVE_FLOAT_PREDICATE_AMBIGUITY_3_ARGS

#define RESOLVE_FLOAT_PREDICATE_AMBIGUITY_3_ARGS ( Func)    RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_3_ARGS(Func, bool)

Definition at line 184 of file ResolveTypeAmbiguity.h.

◆ RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_2_ARGS

#define RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_2_ARGS ( Func,
ReturnType )    MIX_FLOATS_TO_TYPE_2_ARGS(Func, ReturnType);

Definition at line 176 of file ResolveTypeAmbiguity.h.

◆ RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_3_ARGS

#define RESOLVE_FLOAT_TO_TYPE_AMBIGUITY_3_ARGS ( Func,
ReturnType )    MIX_FLOATS_TO_TYPE_3_ARGS(Func, ReturnType);

Definition at line 179 of file ResolveTypeAmbiguity.h.