Compile-time NameDecoder #3179
Replies: 3 comments 1 reply
-
I think this should rather be discussed in an issue, right @alxbilger ? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
NameDecoder has functions to get the name, template name, namespace etc as a string based on a type. Currently, functions are runtime.
Since types are known at compile-time, it would make sense that NameDecoder could be
constexpr
.The problem is that C++ does not offer compile-time and portable features to do such a thing.
I found a solution on the web, but it is not portable:
It uses
__PRETTY_FUNCTION__
(for clang and msvc) and__FUNCSIG__
for msvc.Some problems with this solution:
__FUNCSIG__
might not be defined depending on the compilation options.__PRETTY_FUNCTION__
is not defined with old gccOpen-source libraries I found (such as /~https://github.com/Manu343726/ctti or /~https://github.com/adambadura/type_name) also use the
__PRETTY_FUNCTION__
solution.I think it would not affect any of us if we start using this non-portable C++ since the modern compilers that we use support it. But, to be safe, I start the discussion if we go to this direction.
Beta Was this translation helpful? Give feedback.
All reactions