-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let PrintInfo use Info() in process base class. #11288
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure this does not work reliably across compilers. To my knowledge there is no portable way to get the name of the class
Waiting for comments from @KratosMultiphysics/technical-committee
I agree that different compilers may yield different results. According to cppreference.com:
The intent here was to avoid repeating the class name (in In essence, the question is whether we would like to continue repeating class names (at the cost of more code and the possibility that the information becomes inaccurate at some point in time) or that we would like to have an adequate (but not perfect) solution that works for most practical cases. If there are any usages of |
compiler-dependent behaviour is bad already, but there's just no point in sending mangled names to the user. It's not a great solution, but you could just write a test in python that scans a module for classes, and catches those whose type name doesn't match up with what Another solution would be to make P.S.: we won't be able to solve this problem reliably until C++ gets reflections, but that won't happen in our lifetime. Better not rely on |
To avoid necessity of overriding PrintInfo in derived classes.
ecf383f
to
e5f032a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this is a nice improvement. Could someone from the @KratosMultiphysics/technical-committee please have a look? Thanks.
I agree that would be usefull but @philbucher and @matekelemen are right. Imo (personal opinion, not as tc) if we want to go ahead with this we should use an utility or a macro that demangles it for the main compilers (gcc, clang, icc) and extract the name using a trick like using template<typename TType>
std::string type_name() { return __PRETTY_FUNCTION__; }
std::string demangle(std::string mangled) {
# compilers ifdefs....
}
std::cout << demangle(type_name<Class>) << std::endl; |
Please note that we have taken out the change to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ok to me now :)
Info() and PrintInfo() contain repeated text strings that made override in derived classes necessary.
This commit changes the PrintInfo() implementation such that it uses Info(). This avoids overrides in derived classes if only its default behavior is wanted.