mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Misc: Allow all kinds of non-map containers in grid searchers
This commit is contained in:
@@ -191,26 +191,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
|
||||
template<typename T>
|
||||
static void InserterOf(void* ref, Type&& type)
|
||||
{
|
||||
static_cast<T*>(ref)->push_back(std::move(type));
|
||||
}
|
||||
|
||||
protected:
|
||||
template<typename T>
|
||||
ContainerInserter(T& ref_) : ref(&ref_), inserter(&InserterOf<T>) { }
|
||||
|
||||
void Insert(Type type)
|
||||
ContainerInserter(T& ref_) : ref(&ref_)
|
||||
{
|
||||
inserter(ref, std::move(type));
|
||||
inserter = [](void* containerRaw, Type&& object)
|
||||
{
|
||||
T* container = reinterpret_cast<T*>(containerRaw);
|
||||
container->insert(container->end(), std::move(object));
|
||||
};
|
||||
}
|
||||
|
||||
void Insert(Type object)
|
||||
{
|
||||
inserter(ref, std::move(object));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user