Просмотр исходного кода

stl: version.hpp and ENTT_HAS_VERSION macro

skypjack 23 часов назад
Родитель
Сommit
2b09786326

+ 1 - 0
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

+ 2 - 3
src/entt/config/config.h

@@ -5,6 +5,7 @@
 #    include <entt/ext/config.h>
 #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(<version>)
-#    include <version>
-#
+#ifdef ENTT_HAS_VERSION
 #    if defined(__cpp_consteval)
 #        define ENTT_CONSTEVAL consteval
 #    endif

+ 4 - 4
src/entt/core/ranges.hpp

@@ -1,9 +1,9 @@
 #ifndef ENTT_CORE_RANGES_HPP
 #define ENTT_CORE_RANGES_HPP
 
-#if __has_include(<version>)
-#    include <version>
-#
+#include "../stl/version.hpp"
+
+#ifdef ENTT_HAS_VERSION
 #    if defined(__cpp_lib_ranges)
 #        include <ranges>
 #        include "iterator.hpp"
@@ -17,4 +17,4 @@ inline constexpr bool std::ranges::enable_view<entt::iterable_adaptor<Args...>>{
 #    endif
 #endif
 
-#endif
+#endif

+ 4 - 4
src/entt/entity/ranges.hpp

@@ -1,9 +1,9 @@
 #ifndef ENTT_ENTITY_RANGES_HPP
 #define ENTT_ENTITY_RANGES_HPP
 
-#if __has_include(<version>)
-#    include <version>
-#
+#include "../stl/version.hpp"
+
+#ifdef ENTT_HAS_VERSION
 #    if defined(__cpp_lib_ranges)
 #        include <ranges>
 #        include "fwd.hpp"
@@ -23,4 +23,4 @@ inline constexpr bool std::ranges::enable_view<entt::basic_group<Args...>>{true}
 #    endif
 #endif
 
-#endif
+#endif

+ 1 - 0
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

+ 2 - 3
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(<version>)
-#        include <version>
-#
+#    ifdef ENTT_HAS_VERSION
 #        if defined(__cpp_lib_ranges)
 #            define ENTT_HAS_IDENTITY
 #            include <functional>

+ 2 - 3
src/entt/stl/iterator.hpp

@@ -3,6 +3,7 @@
 
 #include <iterator>
 #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(<version>)
-#        include <version>
-#
+#    ifdef ENTT_HAS_VERSION
 #        if defined(__cpp_lib_ranges)
 #            define ENTT_HAS_ITERATOR_CONCEPTS
 

+ 2 - 3
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(<version>)
-#        include <version>
-#
+#    ifdef ENTT_HAS_VERSION
 #        if defined(__cpp_lib_to_address)
 #            define ENTT_HAS_TO_ADDRESS
 #            include <memory>

+ 9 - 0
src/entt/stl/version.hpp

@@ -0,0 +1,9 @@
+#ifndef ENTT_STL_VERSION_HPP
+#define ENTT_STL_VERSION_HPP
+
+#if __has_include(<version>)
+#    include <version>
+#    define ENTT_HAS_VERSION
+#endif
+
+#endif