1
0
Эх сурвалжийг харах

stl: allow injecting functional

skypjack 4 өдөр өмнө
parent
commit
19b2ed94e7

+ 14 - 12
src/entt/stl/functional.hpp

@@ -1,11 +1,14 @@
 #ifndef ENTT_STL_FUNCTIONAL_HPP
 #ifndef ENTT_STL_FUNCTIONAL_HPP
 #define ENTT_STL_FUNCTIONAL_HPP
 #define ENTT_STL_FUNCTIONAL_HPP
 
 
-#include <functional>
-#include <version>
-#include "../config/config.h"
-
 /*! @cond ENTT_INTERNAL */
 /*! @cond ENTT_INTERNAL */
+#if __has_include(<entt/ext/stl/functional.hpp>)
+#    include <entt/ext/stl/functional.hpp>
+#else
+#    include <functional>
+#    include <version>
+#    include "../config/config.h"
+
 namespace entt::stl {
 namespace entt::stl {
 
 
 using std::equal_to;
 using std::equal_to;
@@ -16,21 +19,19 @@ using std::less;
 
 
 } // namespace entt::stl
 } // namespace entt::stl
 
 
-#ifndef ENTT_FORCE_STL
-#    if defined(__cpp_lib_ranges)
-#        define ENTT_HAS_IDENTITY
-
+#    ifndef ENTT_FORCE_STL
+#        if defined(__cpp_lib_ranges)
+#            define ENTT_HAS_IDENTITY
 namespace entt::stl {
 namespace entt::stl {
 
 
 using std::identity;
 using std::identity;
 
 
 } // namespace entt::stl
 } // namespace entt::stl
-
+#        endif
 #    endif
 #    endif
-#endif
 
 
-#ifndef ENTT_HAS_IDENTITY
-#    include <utility>
+#    ifndef ENTT_HAS_IDENTITY
+#        include <utility>
 
 
 namespace entt::stl {
 namespace entt::stl {
 
 
@@ -44,6 +45,7 @@ struct identity {
 };
 };
 
 
 } // namespace entt::stl
 } // namespace entt::stl
+#    endif
 
 
 #endif
 #endif
 /*! @endcond */
 /*! @endcond */

+ 4 - 0
test/entt/stl_ext/functional.cpp

@@ -1,2 +1,6 @@
 #include <gtest/gtest.h>
 #include <gtest/gtest.h>
 #include <entt/stl/functional.hpp>
 #include <entt/stl/functional.hpp>
+
+TEST(Functional, HasInclude) {
+    static_assert(entt::stl::entt_ext_functional, "Header not properly included");
+}

+ 13 - 0
test/include/entt/ext/stl/functional.hpp

@@ -0,0 +1,13 @@
+#ifndef ENTT_EXT_STL_FUNCTIONAL_HPP
+#define ENTT_EXT_STL_FUNCTIONAL_HPP
+
+/*! @cond ENTT_INTERNAL */
+#include <functional>
+
+namespace entt::stl {
+using namespace std;
+static constexpr auto entt_ext_functional = true;
+} // namespace entt::stl
+/*! @endcond */
+
+#endif