From 2b0978632602e889e8252d3be215ec9c163be6be Mon Sep 17 00:00:00 2001 From: skypjack Date: Wed, 15 Apr 2026 09:09:21 +0200 Subject: [PATCH] stl: version.hpp and ENTT_HAS_VERSION macro --- CMakeLists.txt | 1 + src/entt/config/config.h | 5 ++--- src/entt/core/ranges.hpp | 8 ++++---- src/entt/entity/ranges.hpp | 8 ++++---- src/entt/entt.hpp | 1 + src/entt/stl/functional.hpp | 5 ++--- src/entt/stl/iterator.hpp | 5 ++--- src/entt/stl/memory.hpp | 5 ++--- src/entt/stl/version.hpp | 9 +++++++++ 9 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 src/entt/stl/version.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3409fc1ab..a108c8bfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,7 @@ if(ENTT_INCLUDE_HEADERS) stl/type_traits.hpp stl/utility.hpp stl/vector.hpp + stl/version.hpp tools/davey.hpp entt.hpp fwd.hpp diff --git a/src/entt/config/config.h b/src/entt/config/config.h index 308459922..e98f63c83 100644 --- a/src/entt/config/config.h +++ b/src/entt/config/config.h @@ -5,6 +5,7 @@ # include #endif +#include "../stl/version.hpp" #include "version.h" // NOLINTBEGIN(cppcoreguidelines-macro-usage) @@ -23,9 +24,7 @@ # define ENTT_CATCH if(false) #endif -#if __has_include() -# include -# +#ifdef ENTT_HAS_VERSION # if defined(__cpp_consteval) # define ENTT_CONSTEVAL consteval # endif diff --git a/src/entt/core/ranges.hpp b/src/entt/core/ranges.hpp index c1d062c70..fe58404ef 100644 --- a/src/entt/core/ranges.hpp +++ b/src/entt/core/ranges.hpp @@ -1,9 +1,9 @@ #ifndef ENTT_CORE_RANGES_HPP #define ENTT_CORE_RANGES_HPP -#if __has_include() -# include -# +#include "../stl/version.hpp" + +#ifdef ENTT_HAS_VERSION # if defined(__cpp_lib_ranges) # include # include "iterator.hpp" @@ -17,4 +17,4 @@ inline constexpr bool std::ranges::enable_view>{ # endif #endif -#endif \ No newline at end of file +#endif diff --git a/src/entt/entity/ranges.hpp b/src/entt/entity/ranges.hpp index a80c84edd..ebb379559 100644 --- a/src/entt/entity/ranges.hpp +++ b/src/entt/entity/ranges.hpp @@ -1,9 +1,9 @@ #ifndef ENTT_ENTITY_RANGES_HPP #define ENTT_ENTITY_RANGES_HPP -#if __has_include() -# include -# +#include "../stl/version.hpp" + +#ifdef ENTT_HAS_VERSION # if defined(__cpp_lib_ranges) # include # include "fwd.hpp" @@ -23,4 +23,4 @@ inline constexpr bool std::ranges::enable_view>{true} # endif #endif -#endif \ No newline at end of file +#endif diff --git a/src/entt/entt.hpp b/src/entt/entt.hpp index 334b178d9..f215dc9d3 100644 --- a/src/entt/entt.hpp +++ b/src/entt/entt.hpp @@ -86,4 +86,5 @@ namespace entt::stl {} #include "stl/type_traits.hpp" #include "stl/utility.hpp" #include "stl/vector.hpp" +#include "stl/version.hpp" // IWYU pragma: end_exports diff --git a/src/entt/stl/functional.hpp b/src/entt/stl/functional.hpp index 3fdc6c313..55c455f7c 100644 --- a/src/entt/stl/functional.hpp +++ b/src/entt/stl/functional.hpp @@ -2,12 +2,11 @@ #define ENTT_STL_FUNCTIONAL_HPP #include "../config/config.h" +#include "version.hpp" /*! @cond ENTT_INTERNAL */ #ifndef ENTT_FORCE_STL -# if __has_include() -# include -# +# ifdef ENTT_HAS_VERSION # if defined(__cpp_lib_ranges) # define ENTT_HAS_IDENTITY # include diff --git a/src/entt/stl/iterator.hpp b/src/entt/stl/iterator.hpp index 4b285d4c2..70ed188ff 100644 --- a/src/entt/stl/iterator.hpp +++ b/src/entt/stl/iterator.hpp @@ -3,6 +3,7 @@ #include #include "../config/config.h" +#include "version.hpp" /*! @cond ENTT_INTERNAL */ namespace entt::stl { @@ -17,9 +18,7 @@ using std::random_access_iterator_tag; using std::reverse_iterator; #ifndef ENTT_FORCE_STL -# if __has_include() -# include -# +# ifdef ENTT_HAS_VERSION # if defined(__cpp_lib_ranges) # define ENTT_HAS_ITERATOR_CONCEPTS diff --git a/src/entt/stl/memory.hpp b/src/entt/stl/memory.hpp index eb663d5a9..5c4f6d448 100644 --- a/src/entt/stl/memory.hpp +++ b/src/entt/stl/memory.hpp @@ -2,12 +2,11 @@ #define ENTT_STL_MEMORY_HPP #include "../config/config.h" +#include "version.hpp" /*! @cond ENTT_INTERNAL */ #ifndef ENTT_FORCE_STL -# if __has_include() -# include -# +# ifdef ENTT_HAS_VERSION # if defined(__cpp_lib_to_address) # define ENTT_HAS_TO_ADDRESS # include diff --git a/src/entt/stl/version.hpp b/src/entt/stl/version.hpp new file mode 100644 index 000000000..bcf9c2178 --- /dev/null +++ b/src/entt/stl/version.hpp @@ -0,0 +1,9 @@ +#ifndef ENTT_STL_VERSION_HPP +#define ENTT_STL_VERSION_HPP + +#if __has_include() +# include +# define ENTT_HAS_VERSION +#endif + +#endif