Source

Alt text:

A screenshot from the linked article titled “Reflection in C++26”, showing reflection as one of the bullet points listed in the “Core Language” section

  • GetOffMyLan@programming.dev
    link
    fedilink
    arrow-up
    8
    ·
    edit-2
    3 months ago

    You can also optimize this a bit.

    You can use Activator.CreateInstance instead of reflecting and invoking the constructor.

    You can also call MethodInfo.Invoke, you don’t need to create a delegate.

    Also worth noting that Source Generators have replaced the need for reflection in many cases.