From 2fdc2dc748035b79b7262a7f80b99f6df723b5e1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 27 Aug 2018 20:19:19 +0200 Subject: [PATCH] Clarify the support of constexpr --- glm/detail/setup.hpp | 8 +++++--- manual.md | 4 +++- readme.md | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 4b39b311..d57cc557 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -274,12 +274,14 @@ // N2235 Generalized Constant Expressions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf // N3652 Extended Constant Expressions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html -#if (GLM_COMPILER & GLM_COMPILER_CLANG) && !(GLM_ARCH & GLM_ARCH_SIMD_BIT) +#if (GLM_ARCH & GLM_ARCH_SIMD_BIT) // Compiler SIMD intrinsics don't support constexpr... +# define GLM_HAS_CONSTEXPR 0 +#elif (GLM_COMPILER & GLM_COMPILER_CLANG) # define GLM_HAS_CONSTEXPR __has_feature(cxx_relaxed_constexpr) -#elif (GLM_LANG & GLM_LANG_CXX14_FLAG) && !(GLM_ARCH & GLM_ARCH_SIMD_BIT) +#elif (GLM_LANG & GLM_LANG_CXX14_FLAG) # define GLM_HAS_CONSTEXPR 1 #else -# define GLM_HAS_CONSTEXPR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && !(GLM_ARCH & GLM_ARCH_SIMD_BIT) && GLM_HAS_INITIALIZER_LISTS && (\ +# define GLM_HAS_CONSTEXPR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && GLM_HAS_INITIALIZER_LISTS && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL17)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)))) #endif diff --git a/manual.md b/manual.md index 993e79c5..e9441e89 100644 --- a/manual.md +++ b/manual.md @@ -390,12 +390,14 @@ For example, if a program is compiled with Visual Studio using `/arch:AVX`, GLM It’s possible to avoid the instruction set detection by forcing the use of a specific instruction set with one of the fallowing define: `GLM_FORCE_SSE2`, `GLM_FORCE_SSE3`, `GLM_FORCE_SSSE3`, `GLM_FORCE_SSE41`, `GLM_FORCE_SSE42`, `GLM_FORCE_AVX`, `GLM_FORCE_AVX2` or `GLM_FORCE_AVX512`. -The use of intrinsic functions by GLM implementation can be avoided using the define `GLM_FORCE_PURE` before any inclusion of GLM headers. +The use of intrinsic functions by GLM implementation can be avoided using the define `GLM_FORCE_PURE` before any inclusion of GLM headers. This can be particularly useful if we want to rely on C++14 `constexpr`. ```cpp #define GLM_FORCE_PURE #include +static_assert(glm::vec4::length() == 4, "Using GLM C++ 14 constexpr support for compile time tests"); + // GLM code will be compiled using pure C++ code without any intrinsics ``` diff --git a/readme.md b/readme.md index dfd97d82..16052c15 100644 --- a/readme.md +++ b/readme.md @@ -67,6 +67,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Added identity functions #765 - Splitted headers into EXT extensions to improve compilation time #670 - Added separated performance tests +- Refactor manual, lists all configuration defines #### Fixes: - Fixed SIMD detection on Clang and GCC