这个方法的参数代码是什么意思呢?

Mar*_*sir 2 c++ templates unreal-engine4 unreal-engine5

正如标题所说,TBitArray<>没有确切的类型,那么这是否意味着该方法可以接受任何诸如TBitArray<int32>, TBitArray<float>, ... 作为参数?

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;
}
Run Code Online (Sandbox Code Playgroud)

这段代码有什么区别

template<class T>
FORCEINLINE bool HasAll(const TBitArray<T>& Other) const
Run Code Online (Sandbox Code Playgroud)

S.M*_*.M. 6

TBitArray<>是一个具有所有默认模板参数的模板类。如果它是TBitArray<int32>TBitArray<float>取决于模板定义。

是它的定义:

template<typename Allocator = FDefaultBitArrayAllocator>
class TBitArray;
Run Code Online (Sandbox Code Playgroud)

所以,它既不是int32也不是float,它是默认的数组分配器。

  • @RemyLebeau他们不能工作,他们是OP假设,但无效。 (4认同)