Sfoglia il codice sorgente

stl: allow injecting limits

skypjack 3 settimane fa
parent
commit
6ecae990ee

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

@@ -1,14 +1,18 @@
 #ifndef ENTT_STL_LIMITS_HPP
 #ifndef ENTT_STL_LIMITS_HPP
 #define ENTT_STL_LIMITS_HPP
 #define ENTT_STL_LIMITS_HPP
 
 
-#include <limits>
-
 /*! @cond ENTT_INTERNAL */
 /*! @cond ENTT_INTERNAL */
+#if __has_include(<entt/ext/stl/limits.hpp>)
+#    include <entt/ext/stl/limits.hpp>
+#else
+#    include <limits>
+
 namespace entt::stl {
 namespace entt::stl {
 
 
 using std::numeric_limits;
 using std::numeric_limits;
 
 
 } // namespace entt::stl
 } // namespace entt::stl
+#endif
 /*! @endcond */
 /*! @endcond */
 
 
 #endif
 #endif

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

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

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

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