I have a string:
B<T>::B() [with T = int]
Is there any way I can get
B<T> [with T = int] from this before run time somehow? 🙂
Simplifying: Is there any way to get X & Y separately from a static string XY defined as a preprocessor macro in any form before runtime?
In current C++ I cannot think on a way to split the string at compile time. Most of the template tricks will not work on string literals. Now, I imagine that you want this to use in some sort of logging mechanism and you want to avoid the impact of performing the split at runtime in each method invocation. If that is the case, consider adding a function that will perform the operation and then in each function a
static const std::stringto hold the value. That string will be initialized only once in the first call to the function:(I have not tested this, so you might need to fiddle with it)
This will have some runtime impact, but only once for each function. Also note that this approach is not thread safe: if two threads simultaneously call a method that has not been called before there will be a race condition.