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
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
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.