Преглед на файлове

stl: support injecting cmath

skypjack преди 5 дни
родител
ревизия
ab227a3ef0
променени са 3 файла, в които са добавени 23 реда и са изтрити 2 реда
  1. 6 2
      src/entt/stl/cmath.hpp
  2. 4 0
      test/entt/stl_ext/cmath.cpp
  3. 13 0
      test/include/entt/ext/stl/cmath.hpp

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

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

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

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

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

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