From a02d36f18c5846fc4306cb602851744cb352fc57 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 4 Sep 2020 18:34:36 +0200 Subject: [PATCH] Core/Misc: Allow all kinds of non-map containers in grid searchers --- .../game/Grids/Notifiers/GridNotifiers.h | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 697112972f4..0b8c45051ed 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -191,26 +191,27 @@ namespace Trinity // Generic base class to insert elements into arbitrary containers using push_back template - class ContainerInserter { + class ContainerInserter + { using InserterType = void(*)(void*, Type&&); void* ref; InserterType inserter; - // MSVC workaround - template - static void InserterOf(void* ref, Type&& type) - { - static_cast(ref)->push_back(std::move(type)); - } - protected: template - ContainerInserter(T& ref_) : ref(&ref_), inserter(&InserterOf) { } - - void Insert(Type type) + ContainerInserter(T& ref_) : ref(&ref_) { - inserter(ref, std::move(type)); + inserter = [](void* containerRaw, Type&& object) + { + T* container = reinterpret_cast(containerRaw); + container->insert(container->end(), std::move(object)); + }; + } + + void Insert(Type object) + { + inserter(ref, std::move(object)); } };