Added partial constexpr support detection

This commit is contained in:
Christophe Riccio 2015-02-09 22:02:03 +01:00
parent fad35c4e87
commit 19066e9940

View file

@ -535,11 +535,14 @@
// N2235
#if GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG)
# define GLM_HAS_CONSTEXPR __has_feature(cxx_constexpr)
# define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR
#elif GLM_LANG & GLM_LANG_CXX11_FLAG
# define GLM_HAS_CONSTEXPR 1
# define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR
#else
# define GLM_HAS_CONSTEXPR (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)))
# define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015))
#endif
// N2672
@ -930,6 +933,29 @@ namespace detail
# endif
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////
// countof
#ifndef __has_feature
# define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
#if GLM_HAS_CONSTEXPR_PARTIAL
namespace glm
{
template <typename T, std::size_t N>
constexpr std::size_t countof(T const (&)[N])
{
return N;
}
}//namespace glm
# define GLM_COUNTOF(arr) glm::countof(arr)
#elif _MSC_VER
# define GLM_COUNTOF(arr) _countof(arr)
#else
# define GLM_COUNTOF(arr) sizeof(arr) / sizeof(arr[0])
#endif
///////////////////////////////////////////////////////////////////////////////////
// Uninitialize constructors