mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Work around Windows's definition of min
/max
This allows us to use `std::min`/`std::max`.
This commit is contained in:
parent
369c217db5
commit
eb2823231f
|
@ -3013,6 +3013,7 @@ foreach(target ${TARGETS_OWN})
|
||||||
target_compile_options(${target} PRIVATE /wd4800) # Implicit conversion of int to bool.
|
target_compile_options(${target} PRIVATE /wd4800) # Implicit conversion of int to bool.
|
||||||
endif()
|
endif()
|
||||||
if(TARGET_OS STREQUAL "windows")
|
if(TARGET_OS STREQUAL "windows")
|
||||||
|
target_compile_definitions(${target} PRIVATE NOMINMAX) # windows.h shouldn't define min/max macros
|
||||||
target_compile_definitions(${target} PRIVATE UNICODE) # Windows headers
|
target_compile_definitions(${target} PRIVATE UNICODE) # Windows headers
|
||||||
target_compile_definitions(${target} PRIVATE _UNICODE) # C-runtime
|
target_compile_definitions(${target} PRIVATE _UNICODE) # C-runtime
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -95,22 +95,22 @@ constexpr float pi = 3.1415926535897932384626433f;
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T minimum(T a, T b)
|
constexpr inline T minimum(T a, T b)
|
||||||
{
|
{
|
||||||
return a < b ? a : b;
|
return std::min(a, b);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T minimum(T a, T b, T c)
|
constexpr inline T minimum(T a, T b, T c)
|
||||||
{
|
{
|
||||||
return minimum(minimum(a, b), c);
|
return std::min(std::min(a, b), c);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T maximum(T a, T b)
|
constexpr inline T maximum(T a, T b)
|
||||||
{
|
{
|
||||||
return a > b ? a : b;
|
return std::max(a, b);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T maximum(T a, T b, T c)
|
constexpr inline T maximum(T a, T b, T c)
|
||||||
{
|
{
|
||||||
return maximum(maximum(a, b), c);
|
return std::max(std::max(a, b), c);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T absolute(T a)
|
constexpr inline T absolute(T a)
|
||||||
|
|
Loading…
Reference in a new issue