samedi 23 juillet 2016

C++ Providing arbitrary parameter for a templated array to check against?

Lets say I have a struct

struct FStruct
{
    FName ObjectName;
};

And I have a templated static function

template <typename T, typename LookType>
static T* GetFromArray(LookType LookFor, TArray<T> InArray)
{
    for (T* TIter : InArray)
    {
        if (LookFor == TIter.LookParameter)  // <-- How to provide LookParameter?
        {
            return TIter;
        }
    }

    return nullptr;
}

I need to provide it a variable from that ObjClass to check against, how do I do that?

Essentially the usage could be something like:

MyStaticLib::GetFromArray<FStruct, FName>(FName("Bob"), PeopleArray, FStruct::ObjectName)

Aucun commentaire:

Enregistrer un commentaire