0

I came across the following piece of code inside UE.

template <typename OtherClassType>
FORCEINLINE bool IsA( OtherClassType SomeBase ) const
{
    // We have a cyclic dependency between UObjectBaseUtility and UClass,
    // so we use a template to allow inlining of something we haven't yet seen, because it delays compilation until the function is called.

    // 'static_assert' that this thing is actually a UClass pointer or convertible to it.
    const UClass* SomeBaseClass = SomeBase;
    (void)SomeBaseClass;
    checkfSlow(SomeBaseClass, TEXT("IsA(NULL) cannot yield meaningful results"));

    const UClass* ThisClass = GetClass();

    // Stop the compiler doing some unnecessary branching for nullptr checks
    UE_ASSUME(SomeBaseClass);
    UE_ASSUME(ThisClass);

    return IsChildOfWorkaround(ThisClass, SomeBaseClass);
}

I cannot understand what (void)SomeBaseClass; does.

ChrisMM
  • 8,448
  • 13
  • 29
  • 48
Supreeto
  • 198
  • 9
  • 5
    typically it is used to silence a "not used variable" warning. Though if thats the reason in this code is unclear, because the variable is used – 463035818_is_not_an_ai Mar 29 '22 at 11:26
  • 2
    Basically, it gets rid of "unused variable" warning. But I don't see any reason to use cast to `void` here, `SomeBaseClass` is used three times, shouldn't generate any warnings. – Yksisarvinen Mar 29 '22 at 11:28
  • 3
    It might have been generated by some kind of template, and then not removed when an actual implementation was written. – Karl Knechtel Mar 29 '22 at 11:28

0 Answers0