Ver código fonte

stl: refine functional.hpp + std::function

skypjack 1 mês atrás
pai
commit
3b9304480a
2 arquivos alterados com 10 adições e 5 exclusões
  1. 2 3
      src/entt/signal/emitter.hpp
  2. 8 2
      src/entt/stl/functional.hpp

+ 2 - 3
src/entt/signal/emitter.hpp

@@ -1,7 +1,6 @@
 #ifndef ENTT_SIGNAL_EMITTER_HPP
 #ifndef ENTT_SIGNAL_EMITTER_HPP
 #define ENTT_SIGNAL_EMITTER_HPP
 #define ENTT_SIGNAL_EMITTER_HPP
 
 
-#include <functional>
 #include "../container/dense_map.hpp"
 #include "../container/dense_map.hpp"
 #include "../core/compressed_pair.hpp"
 #include "../core/compressed_pair.hpp"
 #include "../core/fwd.hpp"
 #include "../core/fwd.hpp"
@@ -35,7 +34,7 @@ namespace entt {
 template<typename Derived, typename Allocator>
 template<typename Derived, typename Allocator>
 class emitter {
 class emitter {
     using key_type = id_type;
     using key_type = id_type;
-    using mapped_type = std::function<void(void *)>;
+    using mapped_type = stl::function<void(void *)>;
 
 
     using alloc_traits = stl::allocator_traits<Allocator>;
     using alloc_traits = stl::allocator_traits<Allocator>;
     using container_allocator = alloc_traits::template rebind_alloc<stl::pair<const key_type, mapped_type>>;
     using container_allocator = alloc_traits::template rebind_alloc<stl::pair<const key_type, mapped_type>>;
@@ -135,7 +134,7 @@ public:
      * @param func The listener to register.
      * @param func The listener to register.
      */
      */
     template<typename Type>
     template<typename Type>
-    void on(std::function<void(Type &, Derived &)> func) {
+    void on(stl::function<void(Type &, Derived &)> func) {
         handlers.first().insert_or_assign(type_id<Type>().hash(), [func = stl::move(func), this](void *value) {
         handlers.first().insert_or_assign(type_id<Type>().hash(), [func = stl::move(func), this](void *value) {
             func(*static_cast<Type *>(value), static_cast<Derived &>(*this));
             func(*static_cast<Type *>(value), static_cast<Derived &>(*this));
         });
         });

+ 8 - 2
src/entt/stl/functional.hpp

@@ -1,15 +1,21 @@
 #ifndef ENTT_STL_FUNCTIONAL_HPP
 #ifndef ENTT_STL_FUNCTIONAL_HPP
 #define ENTT_STL_FUNCTIONAL_HPP
 #define ENTT_STL_FUNCTIONAL_HPP
 
 
+#include <functional>
 #include "../config/config.h"
 #include "../config/config.h"
 #include "version.hpp"
 #include "version.hpp"
 
 
 /*! @cond ENTT_INTERNAL */
 /*! @cond ENTT_INTERNAL */
+namespace entt::stl {
+
+using std::function;
+
+} // namespace entt::stl
+
 #ifndef ENTT_FORCE_STL
 #ifndef ENTT_FORCE_STL
 #    ifdef ENTT_HAS_VERSION
 #    ifdef ENTT_HAS_VERSION
 #        if defined(__cpp_lib_ranges)
 #        if defined(__cpp_lib_ranges)
 #            define ENTT_HAS_IDENTITY
 #            define ENTT_HAS_IDENTITY
-#            include <functional>
 
 
 namespace entt::stl {
 namespace entt::stl {
 
 
@@ -22,7 +28,7 @@ using std::identity;
 #endif
 #endif
 
 
 #ifndef ENTT_HAS_IDENTITY
 #ifndef ENTT_HAS_IDENTITY
-#    include <utility>
+#    include "utility.hpp"
 
 
 namespace entt::stl {
 namespace entt::stl {