Remove has C++11 STL

This commit is contained in:
christophe
2025-10-19 11:45:26 +02:00
parent 18a1c9d44c
commit ba18d7b089
14 changed files with 54 additions and 736 deletions

View File

@@ -1,394 +0,0 @@
#pragma once
// #define GLM_CXX98_EXCEPTIONS
// #define GLM_CXX98_RTTI
// #define GLM_CXX11_RVALUE_REFERENCES
// Rvalue references - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html
// GLM_CXX11_TRAILING_RETURN
// Rvalue references for *this - GCC not supported
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
// GLM_CXX11_NONSTATIC_MEMBER_INIT
// Initialization of class objects by rvalues - GCC any
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1610.html
// GLM_CXX11_NONSTATIC_MEMBER_INIT
// Non-static data member initializers - GCC 4.7
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2756.htm
// #define GLM_CXX11_VARIADIC_TEMPLATE
// Variadic templates - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf
//
// Extending variadic template template parameters - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf
// #define GLM_CXX11_GENERALIZED_INITIALIZERS
// Initializer lists - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm
// #define GLM_CXX11_STATIC_ASSERT
// Static assertions - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
// #define GLM_CXX11_AUTO_TYPE
// auto-typed variables - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
// #define GLM_CXX11_AUTO_TYPE
// Multi-declarator auto - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1737.pdf
// #define GLM_CXX11_AUTO_TYPE
// Removal of auto as a storage-class specifier - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2546.htm
// #define GLM_CXX11_AUTO_TYPE
// New function declarator syntax - GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm
// #define GLM_CXX11_LAMBDAS
// New wording for C++0x lambdas - GCC 4.5
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2927.pdf
// #define GLM_CXX11_DECLTYPE
// Declared type of an expression - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
//
// Right angle brackets - GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html
//
// Default template arguments for function templates DR226 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226
//
// Solving the SFINAE problem for expressions DR339 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2634.html
// #define GLM_CXX11_ALIAS_TEMPLATE
// Template aliases N2258 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
//
// Extern templates N1987 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
// #define GLM_CXX11_NULLPTR
// Null pointer constant N2431 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
// #define GLM_CXX11_STRONG_ENUMS
// Strongly-typed enums N2347 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
//
// Forward declarations for enums N2764 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf
//
// Generalized attributes N2761 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf
//
// Generalized constant expressions N2235 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf
//
// Alignment support N2341 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
// #define GLM_CXX11_DELEGATING_CONSTRUCTORS
// Delegating constructors N1986 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf
//
// Inheriting constructors N2540 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm
// #define GLM_CXX11_EXPLICIT_CONVERSIONS
// Explicit conversion operators N2437 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
//
// New character types N2249 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2249.html
//
// Unicode string literals N2442 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
//
// Raw string literals N2442 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
//
// Universal character name literals N2170 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2170.html
// #define GLM_CXX11_USER_LITERALS
// User-defined literals N2765 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf
//
// Standard Layout Types N2342 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm
// #define GLM_CXX11_DEFAULTED_FUNCTIONS
// #define GLM_CXX11_DELETED_FUNCTIONS
// Defaulted and deleted functions N2346 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
//
// Extended friend declarations N1791 GCC 4.7
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf
//
// Extending sizeof N2253 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html
// #define GLM_CXX11_INLINE_NAMESPACES
// Inline namespaces N2535 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm
// #define GLM_CXX11_UNRESTRICTED_UNIONS
// Unrestricted unions N2544 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
// #define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS
// Local and unnamed types as template arguments N2657 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
// #define GLM_CXX11_RANGE_FOR
// Range-based for N2930 GCC 4.6
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2930.html
// #define GLM_CXX11_OVERRIDE_CONTROL
// Explicit virtual overrides N2928 N3206 N3272 GCC 4.7
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm
//
// Minimal support for garbage collection and reachability-based leak detection N2670 No
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm
// #define GLM_CXX11_NOEXCEPT
// Allowing move constructors to throw [noexcept] N3050 GCC 4.6 (core language only)
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html
//
// Defining move special member functions N3053 GCC 4.6
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html
//
// Sequence points N2239 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html
//
// Atomic operations N2427 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html
//
// Strong Compare and Exchange N2748 GCC 4.5
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html
//
// Bidirectional Fences N2752 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2752.htm
//
// Memory model N2429 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm
//
// Data-dependency ordering: atomics and memory model N2664 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2664.htm
//
// Propagating exceptions N2179 GCC 4.4
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html
//
// Abandoning a process and at_quick_exit N2440 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2440.htm
//
// Allow atomics use in signal handlers N2547 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2547.htm
//
// Thread-local storage N2659 GCC 4.8
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm
//
// Dynamic initialization and destruction with concurrency N2660 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm
//
// __func__ predefined identifier N2340 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm
//
// C99 preprocessor N1653 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm
//
// long long N1811 GCC 4.3
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf
//
// Extended integral types N1988 Yes
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1988.pdf
#if(GLM_COMPILER & GLM_COMPILER_GCC)
# define GLM_CXX11_STATIC_ASSERT
#elif(GLM_COMPILER & GLM_COMPILER_CLANG)
# if(__has_feature(cxx_exceptions))
# define GLM_CXX98_EXCEPTIONS
# endif
# if(__has_feature(cxx_rtti))
# define GLM_CXX98_RTTI
# endif
# if(__has_feature(cxx_access_control_sfinae))
# define GLM_CXX11_ACCESS_CONTROL_SFINAE
# endif
# if(__has_feature(cxx_alias_templates))
# define GLM_CXX11_ALIAS_TEMPLATE
# endif
# if(__has_feature(cxx_alignas))
# define GLM_CXX11_ALIGNAS
# endif
# if(__has_feature(cxx_attributes))
# define GLM_CXX11_ATTRIBUTES
# endif
# if(__has_feature(cxx_constexpr))
# define GLM_CXX11_CONSTEXPR
# endif
# if(__has_feature(cxx_decltype))
# define GLM_CXX11_DECLTYPE
# endif
# if(__has_feature(cxx_default_function_template_args))
# define GLM_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS
# endif
# if(__has_feature(cxx_defaulted_functions))
# define GLM_CXX11_DEFAULTED_FUNCTIONS
# endif
# if(__has_feature(cxx_delegating_constructors))
# define GLM_CXX11_DELEGATING_CONSTRUCTORS
# endif
# if(__has_feature(cxx_deleted_functions))
# define GLM_CXX11_DELETED_FUNCTIONS
# endif
# if(__has_feature(cxx_explicit_conversions))
# define GLM_CXX11_EXPLICIT_CONVERSIONS
# endif
# if(__has_feature(cxx_generalized_initializers))
# define GLM_CXX11_GENERALIZED_INITIALIZERS
# endif
# if(__has_feature(cxx_implicit_moves))
# define GLM_CXX11_IMPLICIT_MOVES
# endif
# if(__has_feature(cxx_inheriting_constructors))
# define GLM_CXX11_INHERITING_CONSTRUCTORS
# endif
# if(__has_feature(cxx_inline_namespaces))
# define GLM_CXX11_INLINE_NAMESPACES
# endif
# if(__has_feature(cxx_lambdas))
# define GLM_CXX11_LAMBDAS
# endif
# if(__has_feature(cxx_local_type_template_args))
# define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS
# endif
# if(__has_feature(cxx_noexcept))
# define GLM_CXX11_NOEXCEPT
# endif
# if(__has_feature(cxx_nonstatic_member_init))
# define GLM_CXX11_NONSTATIC_MEMBER_INIT
# endif
# if(__has_feature(cxx_nullptr))
# define GLM_CXX11_NULLPTR
# endif
# if(__has_feature(cxx_override_control))
# define GLM_CXX11_OVERRIDE_CONTROL
# endif
# if(__has_feature(cxx_reference_qualified_functions))
# define GLM_CXX11_REFERENCE_QUALIFIED_FUNCTIONS
# endif
# if(__has_feature(cxx_range_for))
# define GLM_CXX11_RANGE_FOR
# endif
# if(__has_feature(cxx_raw_string_literals))
# define GLM_CXX11_RAW_STRING_LITERALS
# endif
# if(__has_feature(cxx_rvalue_references))
# define GLM_CXX11_RVALUE_REFERENCES
# endif
# if(__has_feature(cxx_static_assert))
# define GLM_CXX11_STATIC_ASSERT
# endif
# if(__has_feature(cxx_auto_type))
# define GLM_CXX11_AUTO_TYPE
# endif
# if(__has_feature(cxx_strong_enums))
# define GLM_CXX11_STRONG_ENUMS
# endif
# if(__has_feature(cxx_trailing_return))
# define GLM_CXX11_TRAILING_RETURN
# endif
# if(__has_feature(cxx_unicode_literals))
# define GLM_CXX11_UNICODE_LITERALS
# endif
# if(__has_feature(cxx_unrestricted_unions))
# define GLM_CXX11_UNRESTRICTED_UNIONS
# endif
# if(__has_feature(cxx_user_literals))
# define GLM_CXX11_USER_LITERALS
# endif
# if(__has_feature(cxx_variadic_templates))
# define GLM_CXX11_VARIADIC_TEMPLATES
# endif
#endif//(GLM_COMPILER & GLM_COMPILER_CLANG)

View File

@@ -20,11 +20,6 @@ namespace glm
return (y < x) ? y : x;
}
template<typename T>
struct TMin {
GLM_FUNC_QUALIFIER T operator()(const T& a, const T& b) { return min(a, b); }
};
// max
template<typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType max(genType x, genType y)
@@ -34,10 +29,9 @@ namespace glm
return (x < y) ? y : x;
}
template<typename T>
struct TMax {
GLM_FUNC_QUALIFIER T operator()(const T& a, const T& b) { return max(a, b); }
};
using ::std::round;
using ::std::trunc;
// abs
template<>
@@ -46,58 +40,41 @@ namespace glm
int const y = x >> (sizeof(int) * 8 - 1);
return (x ^ y) - y;
}
}//namespace glm
namespace glm{
namespace detail
{
template<typename T>
struct TMin {
GLM_FUNC_QUALIFIER T operator()(const T& a, const T& b) { return min(a, b); }
};
template<typename T>
struct TMax {
GLM_FUNC_QUALIFIER T operator()(const T& a, const T& b) { return max(a, b); }
};
template<typename T>
struct TAbs {
T operator()(const T& a) { return abs(a); }
};
// round
# if GLM_HAS_CXX11_STL
using ::std::round;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType round(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'round' only accept floating-point inputs");
template<typename T>
struct TRound {
T operator()(const T& a) { return round(a); }
};
return x < static_cast<genType>(0) ? static_cast<genType>(int(x - static_cast<genType>(0.5))) : static_cast<genType>(int(x + static_cast<genType>(0.5)));
}
# endif
template<typename T>
struct TTrunc {
T operator()(const T& a) { return trunc(a); }
};
template<typename T>
struct TRound {
T operator()(const T& a) { return round(a); }
};
template<typename T>
struct TFmod {
T operator()(const T& a, const T& b) { return std::fmod(a, b); }
};
// trunc
# if GLM_HAS_CXX11_STL
using ::std::trunc;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType trunc(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'trunc' only accept floating-point inputs");
return x < static_cast<genType>(0) ? -std::floor(-x) : std::floor(x);
}
# endif
template<typename T>
struct TTrunc {
T operator()(const T& a) { return trunc(a); }
};
template<typename T>
struct TFmod {
T operator()(const T& a, const T& b) { return std::fmod(a, b); }
};
}//namespace glm
namespace glm{
namespace detail
{
template<length_t L, typename T, qualifier Q, bool Aligned>
struct compute_abs_vector
{
@@ -725,33 +702,7 @@ namespace detail
return detail::compute_smoothstep_vector<L, T, Q, detail::is_aligned<Q>::value>::call(edge0, edge1, x);
}
# if GLM_HAS_CXX11_STL
using std::isnan;
# else
template<typename genType>
GLM_FUNC_QUALIFIER bool isnan(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'isnan' only accept floating-point inputs");
# if GLM_HAS_CXX11_STL
return std::isnan(x);
# elif GLM_COMPILER & GLM_COMPILER_VC
return _isnan(x) != 0;
# elif GLM_COMPILER & GLM_COMPILER_INTEL
# if GLM_PLATFORM & GLM_PLATFORM_WINDOWS
return _isnan(x) != 0;
# else
return ::isnan(x) != 0;
# endif
# elif (GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) && (GLM_PLATFORM & GLM_PLATFORM_ANDROID) && __cplusplus < 201103L
return _isnan(x) != 0;
# elif (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP)
return ::isnan(x) != 0;
# else
return std::isnan(x);
# endif
}
# endif
using std::isnan;
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, bool, Q> isnan(vec<L, T, Q> const& v)
@@ -764,36 +715,7 @@ namespace detail
return Result;
}
# if GLM_HAS_CXX11_STL
using std::isinf;
# else
template<typename genType>
GLM_FUNC_QUALIFIER bool isinf(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'isinf' only accept floating-point inputs");
# if GLM_HAS_CXX11_STL
return std::isinf(x);
# elif GLM_COMPILER & (GLM_COMPILER_INTEL | GLM_COMPILER_VC)
# if(GLM_PLATFORM & GLM_PLATFORM_WINDOWS)
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
# else
return ::isinf(x);
# endif
# elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)
# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L)
return _isinf(x) != 0;
# else
return std::isinf(x);
# endif
# elif (GLM_COMPILER & GLM_COMPILER_CUDA) || (GLM_COMPILER & GLM_COMPILER_HIP)
// http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/group__CUDA__MATH__DOUBLE_g13431dd2b40b51f9139cbb7f50c18fab.html#g13431dd2b40b51f9139cbb7f50c18fab
return ::isinf(double(x)) != 0;
# else
return std::isinf(x);
# endif
}
# endif
using std::isinf;
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, bool, Q> isinf(vec<L, T, Q> const& v)
@@ -882,15 +804,7 @@ namespace detail
return reinterpret_cast<vec<L, float, Q>&>(const_cast<vec<L, uint, Q>&>(v));
}
# if GLM_HAS_CXX11_STL
using std::fma;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType fma(genType const& a, genType const& b, genType const& c)
{
return a * b + c;
}
# endif
using std::fma;
template<typename genType>
GLM_FUNC_QUALIFIER genType frexp(genType x, int& exp)

View File

@@ -10,15 +10,7 @@
namespace glm{
namespace detail
{
# if GLM_HAS_CXX11_STL
using std::log2;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType log2(genType Value)
{
return std::log(Value) * static_cast<genType>(1.4426950408889634073599246810019);
}
# endif
using std::log2;
template<length_t L, typename T, qualifier Q, bool isFloat, bool Aligned>
struct compute_log2
@@ -90,18 +82,7 @@ namespace detail
return detail::functor1<vec, L, T, T, Q>::call(log, x);
}
# if GLM_HAS_CXX11_STL
using std::exp2;
# else
//exp2, ln2 = 0.69314718055994530941723212145818f
template<typename genType>
GLM_FUNC_QUALIFIER genType exp2(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'exp2' only accept floating-point inputs");
return std::exp(static_cast<genType>(0.69314718055994530941723212145818) * x);
}
# endif
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> exp2(vec<L, T, Q> const& x)

View File

@@ -130,17 +130,7 @@ namespace glm
}
// asinh
# if GLM_HAS_CXX11_STL
using std::asinh;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType asinh(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'asinh' only accept floating-point input");
return (x < static_cast<genType>(0) ? static_cast<genType>(-1) : (x > static_cast<genType>(0) ? static_cast<genType>(1) : static_cast<genType>(0))) * log(std::abs(x) + sqrt(static_cast<genType>(1) + x * x));
}
# endif
using std::asinh;
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> asinh(vec<L, T, Q> const& v)
@@ -149,19 +139,7 @@ namespace glm
}
// acosh
# if GLM_HAS_CXX11_STL
using std::acosh;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType acosh(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'acosh' only accept floating-point input");
if(x < static_cast<genType>(1))
return static_cast<genType>(0);
return log(x + sqrt(x * x - static_cast<genType>(1)));
}
# endif
using std::acosh;
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> acosh(vec<L, T, Q> const& v)
@@ -170,19 +148,7 @@ namespace glm
}
// atanh
# if GLM_HAS_CXX11_STL
using std::atanh;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType atanh(genType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'atanh' only accept floating-point input");
if(std::abs(x) >= static_cast<genType>(1))
return 0;
return static_cast<genType>(0.5) * log((static_cast<genType>(1) + x) / (static_cast<genType>(1) - x));
}
# endif
using std::atanh;
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> atanh(vec<L, T, Q> const& v)

View File

@@ -144,29 +144,6 @@
///////////////////////////////////////////////////////////////////////////////////
// Has of C++ features
// http://clang.llvm.org/cxx_status.html
// http://gcc.gnu.org/projects/cxx0x.html
// http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
#if (GLM_COMPILER & GLM_COMPILER_CUDA_RTC) == GLM_COMPILER_CUDA_RTC
# define GLM_HAS_CXX11_STL 0
#elif (GLM_COMPILER & GLM_COMPILER_HIP)
# define GLM_HAS_CXX11_STL 0
#elif GLM_COMPILER & GLM_COMPILER_CLANG
# if (defined(_LIBCPP_VERSION) || (GLM_LANG & GLM_LANG_CXX11_FLAG) || defined(GLM_LANG_STL11_FORCED))
# define GLM_HAS_CXX11_STL 1
# else
# define GLM_HAS_CXX11_STL 0
# endif
#elif GLM_LANG & GLM_LANG_CXX11_FLAG
# define GLM_HAS_CXX11_STL 1
#else
# define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
((GLM_PLATFORM != GLM_PLATFORM_WINDOWS) && (GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15))))
#endif
// N1720
#if GLM_COMPILER & GLM_COMPILER_CLANG
# define GLM_HAS_STATIC_ASSERT __has_feature(cxx_static_assert)

View File

@@ -24,19 +24,7 @@ namespace glm
return (glm::max)((glm::max)(a, b), (glm::max)(c, d));
}
# if GLM_HAS_CXX11_STL
using std::fmin;
# else
template<typename T>
GLM_FUNC_QUALIFIER T fmin(T a, T b)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fmin' only accept floating-point input");
if (isnan(a))
return b;
return min(a, b);
}
# endif
using std::fmin;
template<typename T>
GLM_FUNC_QUALIFIER T (fmin)(T a, T b, T c)
@@ -68,20 +56,7 @@ namespace glm
return (min)(a, b, c, d);
}
# if GLM_HAS_CXX11_STL
using std::fmax;
# else
template<typename T>
GLM_FUNC_QUALIFIER T (fmax)(T a, T b)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fmax' only accept floating-point input");
if (isnan(a))
return b;
return (max)(a, b);
}
# endif
using std::fmax;
template<typename T>
GLM_FUNC_QUALIFIER T (fmax)(T a, T b, T c)

View File

@@ -198,35 +198,19 @@ namespace glm
template<>
GLM_FUNC_QUALIFIER float nextFloat(float x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<float>::max());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MAX);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafterf(x, FLT_MAX);
# else
return nextafterf(x, FLT_MAX);
# endif
return std::nextafter(x, std::numeric_limits<float>::max());
}
template<>
GLM_FUNC_QUALIFIER double nextFloat(double x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<double>::max());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafter(x, std::numeric_limits<double>::max());
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafter(x, DBL_MAX);
# else
return nextafter(x, DBL_MAX);
# endif
return std::nextafter(x, std::numeric_limits<double>::max());
}
template<typename T>
GLM_FUNC_QUALIFIER T nextFloat(T x, int ULPs)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'next_float' only accept floating-point input");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'nextFloat' only accept floating-point input");
assert(ULPs >= 0);
T temp = x;
@@ -237,34 +221,18 @@ namespace glm
GLM_FUNC_QUALIFIER float prevFloat(float x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<float>::min());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MIN);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafterf(x, FLT_MIN);
# else
return nextafterf(x, FLT_MIN);
# endif
return std::nextafter(x, std::numeric_limits<float>::min());
}
GLM_FUNC_QUALIFIER double prevFloat(double x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<double>::min());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return _nextafter(x, DBL_MIN);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafter(x, DBL_MIN);
# else
return nextafter(x, DBL_MIN);
# endif
return std::nextafter(x, std::numeric_limits<double>::min());
}
template<typename T>
GLM_FUNC_QUALIFIER T prevFloat(T x, int ULPs)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'prev_float' only accept floating-point input");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'prevFloat' only accept floating-point input");
assert(ULPs >= 0);
T temp = x;

View File

@@ -7,29 +7,13 @@ namespace glm
template<>
GLM_FUNC_QUALIFIER float next_float(float x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<float>::max());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MAX);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafterf(x, FLT_MAX);
# else
return nextafterf(x, FLT_MAX);
# endif
}
template<>
GLM_FUNC_QUALIFIER double next_float(double x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<double>::max());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafter(x, std::numeric_limits<double>::max());
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafter(x, DBL_MAX);
# else
return nextafter(x, DBL_MAX);
# endif
}
template<typename T>
@@ -46,28 +30,12 @@ namespace glm
GLM_FUNC_QUALIFIER float prev_float(float x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<float>::min());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MIN);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafterf(x, FLT_MIN);
# else
return nextafterf(x, FLT_MIN);
# endif
}
GLM_FUNC_QUALIFIER double prev_float(double x)
{
# if GLM_HAS_CXX11_STL
return std::nextafter(x, std::numeric_limits<double>::min());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return _nextafter(x, DBL_MIN);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return __builtin_nextafter(x, DBL_MIN);
# else
return nextafter(x, DBL_MIN);
# endif
}
template<typename T>

View File

@@ -12,7 +12,7 @@ namespace detail
{
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& a, vec<L, T, Q> const& b)
{
return detail::functor2<vec, L, T, Q>::call(TFmod<T>(), a, b);
return detail::functor2<vec, L, T, Q>::call(detail::TFmod<T>(), a, b);
}
};
@@ -31,11 +31,7 @@ namespace detail
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'isdenormal' only accept floating-point inputs");
# if GLM_HAS_CXX11_STL
return std::fpclassify(x) == FP_SUBNORMAL;
# else
return epsilonNotEqual(x, static_cast<T>(0), epsilon<T>()) && std::fabs(x) < std::numeric_limits<T>::min();
# endif
return std::fpclassify(x) == FP_SUBNORMAL;
}
template<typename T, qualifier Q>

View File

@@ -4,34 +4,20 @@ namespace glm
{
// isfinite
template<typename genType>
GLM_FUNC_QUALIFIER bool isfinite(
genType const& x)
GLM_FUNC_QUALIFIER bool isfinite(genType const& x)
{
# if GLM_HAS_CXX11_STL
return std::isfinite(x) != 0;
# elif GLM_COMPILER & GLM_COMPILER_VC
return _finite(x) != 0;
# elif GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID
return _isfinite(x) != 0;
# else
if (std::numeric_limits<genType>::is_integer || std::denorm_absent == std::numeric_limits<genType>::has_denorm)
return std::numeric_limits<genType>::min() <= x && std::numeric_limits<genType>::max() >= x;
else
return -std::numeric_limits<genType>::max() <= x && std::numeric_limits<genType>::max() >= x;
# endif
return std::isfinite(x) != 0;
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<1, bool, Q> isfinite(
vec<1, T, Q> const& x)
GLM_FUNC_QUALIFIER vec<1, bool, Q> isfinite(vec<1, T, Q> const& x)
{
return vec<1, bool, Q>(
isfinite(x.x));
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<2, bool, Q> isfinite(
vec<2, T, Q> const& x)
GLM_FUNC_QUALIFIER vec<2, bool, Q> isfinite(vec<2, T, Q> const& x)
{
return vec<2, bool, Q>(
isfinite(x.x),
@@ -39,8 +25,7 @@ namespace glm
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<3, bool, Q> isfinite(
vec<3, T, Q> const& x)
GLM_FUNC_QUALIFIER vec<3, bool, Q> isfinite(vec<3, T, Q> const& x)
{
return vec<3, bool, Q>(
isfinite(x.x),
@@ -49,8 +34,7 @@ namespace glm
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, bool, Q> isfinite(
vec<4, T, Q> const& x)
GLM_FUNC_QUALIFIER vec<4, bool, Q> isfinite(vec<4, T, Q> const& x)
{
return vec<4, bool, Q>(
isfinite(x.x),
@@ -60,8 +44,7 @@ namespace glm
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, bool, Q> isfinite(
qua<T, Q> const& x)
GLM_FUNC_QUALIFIER vec<4, bool, Q> isfinite(qua<T, Q> const& x)
{
return vec<4, bool, Q>(
isfinite(x.x),

View File

@@ -1,8 +1,6 @@
/// @ref gtx_pca
#ifndef GLM_HAS_CXX11_STL
#include <algorithm>
#endif
#include <utility>
namespace glm {

View File

@@ -115,11 +115,9 @@ static int test_exp2()
glm::vec4 E = glm::exp2(glm::vec4(4.f, 3.f, 2.f, 1.f));
Error += glm::all(glm::equal(E, glm::vec4(16.f, 8.f, 4.f, 2.f), 0.01f)) ? 0 : 1;
# if GLM_HAS_CXX11_STL
//large exponent
float F = glm::exp2(23.f);
Error += glm::equal(F, 8388608.f, 0.01f) ? 0 : 1;
# endif
return Error;
}

View File

@@ -6,9 +6,7 @@
#include <cstdio>
#include <vector>
#if GLM_HAS_CXX11_STL == 1
#include <random>
#endif
#if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
@@ -444,11 +442,7 @@ static int testEigenvalueSort()
// Test covariance matrix creation functions
template<glm::length_t D, typename T, glm::qualifier Q>
static int testCovar(
#if GLM_HAS_CXX11_STL == 1
glm::length_t dataSize, unsigned int randomEngineSeed
#else // GLM_HAS_CXX11_STL == 1
glm::length_t, unsigned int
#endif // GLM_HAS_CXX11_STL == 1
)
{
typedef glm::vec<D, T, Q> vec;
@@ -469,7 +463,6 @@ static int testCovar(
}
// #2: test function variant consistency with random data
#if GLM_HAS_CXX11_STL == 1
std::default_random_engine rndEng(randomEngineSeed);
std::normal_distribution<T> normalDist;
testData.resize(dataSize);
@@ -500,7 +493,6 @@ static int testCovar(
return failReport(__LINE__);
if(!matrixEpsilonEqual(c1, c4, myEpsilon<T>()))
return failReport(__LINE__);
#endif // GLM_HAS_CXX11_STL == 1
return 0;
}
@@ -587,7 +579,6 @@ static int smokeTest()
return 0;
}
#if GLM_HAS_CXX11_STL == 1
static int rndTest(unsigned int randomEngineSeed)
{
std::default_random_engine rndEng(randomEngineSeed);
@@ -654,7 +645,6 @@ static int rndTest(unsigned int randomEngineSeed)
return 0;
}
#endif // GLM_HAS_CXX11_STL == 1
int main()
{
@@ -716,14 +706,12 @@ int main()
return error;
// Final tests with randomized data
#if GLM_HAS_CXX11_STL == 1
if(rndTest(12345) != 0)
error = failReport(__LINE__);
if(rndTest(42) != 0)
error = failReport(__LINE__);
if (error != 0)
return error;
#endif // GLM_HAS_CXX11_STL == 1
return error;
}

View File

@@ -100,7 +100,7 @@ bool percent_error(const T1& a, const T2& b, float percentThreshold)
for (int j = 0; j < a[i].length(); ++j)
{
value_type v;
if (a[i][j] != value_type(0))
if (glm::abs(a[i][j] - value_type(0)) < glm::epsilon<value_type>())
v = ((b[i][j] - a[i][j]) / a[i][j]) * value_type(100);
else
v = b[i][j] * value_type(100);