Use name pointer for internal type identification #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a possible solution to the problem with
CLASS_NAME
s in shared libraries discussed in #7. Types have the string as a non-constexpr
static member and have a pointer to that static member as theconstexpr
that is used in comparisons etc. This way you have both a human-readable representation and aconstexpr
, with the difference that it must work thanks to the one definition rule.A few things you might want to do differently to this branch:
namePtr
toType
and kept thename
for the sake of simplicity. If you don't want to waste the memory of keepingname
around, it could be a method that simply dereferencesnamePtr
.CLASS_NAME
and called the non-constexpr
stringCLASS_NAME_NONCONSTEXPR
.CLASS_NAMEPTR
andCLASS_NAME
might be better names, but they would require larger changes to the existing code.