From 1a86bab4d870996334400b31b207c122c35bcc32 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 4 Sep 2020 18:34:36 +0200 Subject: Core/Misc: Allow all kinds of non-map containers in grid searchers (cherry picked from commit a02d36f18c5846fc4306cb602851744cb352fc57) --- src/server/game/Grids/Notifiers/GridNotifiers.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') 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 - class ContainerInserter { + class ContainerInserter + { using InserterType = void(*)(void*, Type&&); void* ref; InserterType inserter; - // MSVC workaround + protected: template - static void InserterOf(void* ref, Type&& type) + ContainerInserter(T& ref_) : ref(&ref_) { - static_cast(ref)->push_back(std::move(type)); + inserter = [](void* containerRaw, Type&& object) + { + T* container = reinterpret_cast(containerRaw); + container->insert(container->end(), std::move(object)); + }; } - protected: - template - ContainerInserter(T& ref_) : ref(&ref_), inserter(&InserterOf) { } - - void Insert(Type type) + void Insert(Type object) { - inserter(ref, std::move(type)); + inserter(ref, std::move(object)); } }; -- cgit v1.2.3