aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2020-09-04 18:34:36 +0200
committerShauren <shauren.trinity@gmail.com>2022-02-05 11:51:10 +0100
commit1a86bab4d870996334400b31b207c122c35bcc32 (patch)
tree214350c72472a73ae2ba1a04fbdd9d8c6df8aaf3
parenta0edc1fb1bdd950094b2fffcf14f35aa660a5d16 (diff)
Core/Misc: Allow all kinds of non-map containers in grid searchers
(cherry picked from commit a02d36f18c5846fc4306cb602851744cb352fc57)
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index 2f75b5d7447..bff2785ca1f 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -221,26 +221,27 @@ namespace Trinity
// Generic base class to insert elements into arbitrary containers using push_back
template<typename Type>
- class ContainerInserter {
+ class ContainerInserter
+ {
using InserterType = void(*)(void*, Type&&);
void* ref;
InserterType inserter;
- // MSVC workaround
+ protected:
template<typename T>
- static void InserterOf(void* ref, Type&& type)
+ ContainerInserter(T& ref_) : ref(&ref_)
{
- static_cast<T*>(ref)->push_back(std::move(type));
+ inserter = [](void* containerRaw, Type&& object)
+ {
+ T* container = reinterpret_cast<T*>(containerRaw);
+ container->insert(container->end(), std::move(object));
+ };
}
- protected:
- template<typename T>
- ContainerInserter(T& ref_) : ref(&ref_), inserter(&InserterOf<T>) { }
-
- void Insert(Type type)
+ void Insert(Type object)
{
- inserter(ref, std::move(type));
+ inserter(ref, std::move(object));
}
};