Search code examples
c++templatesunreal-engine4unreal-engine5

What does the parameter code of this method mean?


As the title says, TBitArray<> does not have an exact type, so does it mean that this method can accept any such as TBitArray<int32>, TBitArray<float>, ... as parameters?

FORCEINLINE bool HasAll(const TBitArray<>& Other) const
{
    FConstWordIterator ThisIterator(*this);
    FConstWordIterator OtherIterator(Other);

    while (ThisIterator || OtherIterator)
    {
        const uint32 A = ThisIterator ? ThisIterator.GetWord() : 0;
        const uint32 B = OtherIterator ? OtherIterator.GetWord() : 0;
        if ((A & B) != B)
        {
            return false;
        }

        ++ThisIterator;
        ++OtherIterator;
    }

    return true;
}

And what difference with this code

template<class T>
FORCEINLINE bool HasAll(const TBitArray<T>& Other) const

Solution

  • TBitArray<> is a template class with all default template parameters. If it's TBitArray<int32> or TBitArray<float> depends on the template definition.

    Here is its definition:

    template<typename Allocator = FDefaultBitArrayAllocator>
    class TBitArray;
    

    So, it's neither int32 nor float, it's the default array allocator.