stl: refine functional.hpp + std::function

This commit is contained in:
skypjack
2026-04-16 10:58:25 +02:00
parent fee356c7f9
commit 3b9304480a
2 changed files with 10 additions and 5 deletions

View File

@@ -1,7 +1,6 @@
#ifndef ENTT_SIGNAL_EMITTER_HPP
#define ENTT_SIGNAL_EMITTER_HPP
#include <functional>
#include "../container/dense_map.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/fwd.hpp"
@@ -35,7 +34,7 @@ namespace entt {
template<typename Derived, typename Allocator>
class emitter {
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 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.
*/
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) {
func(*static_cast<Type *>(value), static_cast<Derived &>(*this));
});

View File

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