Browse Source

stl: support injecting type_traits

skypjack 2 weeks ago
parent
commit
e1f380d22c

+ 6 - 2
src/entt/stl/type_traits.hpp

@@ -1,9 +1,12 @@
 #ifndef ENTT_STL_TYPE_TRAITS_HPP
 #ifndef ENTT_STL_TYPE_TRAITS_HPP
 #define ENTT_STL_TYPE_TRAITS_HPP
 #define ENTT_STL_TYPE_TRAITS_HPP
 
 
-#include <type_traits>
-
 /*! @cond ENTT_INTERNAL */
 /*! @cond ENTT_INTERNAL */
+#if __has_include(<entt/ext/stl/type_traits.hpp>)
+#    include <entt/ext/stl/type_traits.hpp>
+#else
+#    include <type_traits>
+
 namespace entt::stl {
 namespace entt::stl {
 
 
 using std::bool_constant;
 using std::bool_constant;
@@ -60,6 +63,7 @@ using std::true_type;
 using std::underlying_type_t;
 using std::underlying_type_t;
 
 
 } // namespace entt::stl
 } // namespace entt::stl
+#endif
 /*! @endcond */
 /*! @endcond */
 
 
 #endif
 #endif

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

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

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

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