فهرست منبع

stl: allow injecting algorithm

skypjack 6 روز پیش
والد
کامیت
daeb16ae0c
3فایلهای تغییر یافته به همراه23 افزوده شده و 3 حذف شده
  1. 6 2
      src/entt/stl/algorithm.hpp
  2. 4 1
      test/entt/stl_ext/algorithm.cpp
  3. 13 0
      test/include/entt/ext/stl/algorithm.hpp

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

@@ -1,9 +1,12 @@
 #ifndef ENTT_STL_ALGORITHM_HPP
 #define ENTT_STL_ALGORITHM_HPP
 
-#include <algorithm>
-
 /*! @cond ENTT_INTERNAL */
+#if __has_include(<entt/ext/stl/algorithm.hpp>)
+#    include <entt/ext/stl/algorithm.hpp>
+#else
+#    include <algorithm>
+
 namespace entt::stl {
 
 using std::all_of;
@@ -13,6 +16,7 @@ using std::none_of;
 using std::sort;
 
 } // namespace entt::stl
+#endif
 /*! @endcond */
 
 #endif

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

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

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

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