Jelajahi Sumber

stl: allow injecting atomic

skypjack 6 hari lalu
induk
melakukan
c0522889e2

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

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

+ 4 - 1
test/entt/stl_ext/atomic.cpp

@@ -1,3 +1,6 @@
-#include <memory>
 #include <gtest/gtest.h>
 #include <entt/stl/atomic.hpp>
+
+TEST(Atomic, HasInclude) {
+    static_assert(entt::stl::entt_ext_atomic, "Header not properly included");
+}

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

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