Browse Source

stl: allow injecting cstddef

skypjack 5 days ago
parent
commit
e1ab4106c7
3 changed files with 23 additions and 2 deletions
  1. 6 2
      src/entt/stl/cstddef.hpp
  2. 4 0
      test/entt/stl_ext/cstddef.cpp
  3. 13 0
      test/include/entt/ext/stl/cstddef.hpp

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

@@ -1,9 +1,12 @@
 #ifndef ENTT_STL_CSTDDEF_HPP
 #define ENTT_STL_CSTDDEF_HPP
 
-#include <cstddef>
-
 /*! @cond ENTT_INTERNAL */
+#if __has_include(<entt/ext/stl/cstddef.hpp>)
+#    include <entt/ext/stl/cstddef.hpp>
+#else
+#    include <cstddef>
+
 namespace entt::stl {
 
 using std::byte;
@@ -12,6 +15,7 @@ using std::ptrdiff_t;
 using std::size_t;
 
 } // namespace entt::stl
+#endif
 /*! @endcond */
 
 #endif

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

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

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

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