Add convenience macro for defining strong types (correctly)#451
Add convenience macro for defining strong types (correctly)#451sleeepyjack merged 2 commits intoNVIDIA:devfrom
Conversation
|
I was thinking of something like this: https://godbolt.org/z/9Pzv71njW. All we need is to add a second template parameter with default and no need to update existing implementations. |
I tried a similar thing earlier today but I found a few problems with this approach. We actually don't need the tparam if we avoid declaring strong types through |
Valid point.
I see. I guess me just not a macro fan then :), e.g.
|
PointKernel
left a comment
There was a problem hiding this comment.
The goal of this PR is to resolve the strong type conflicts and the detail (like using macro or something else) can be adjusted upon use.
Looks great.
I'm also not a macro fan TBH but I can't find a better way to avoid typing the same code pattern for the struct definition over and over. 🙃 I added a few hints to the sentinel inline docs in my most recent commit so users at least know the names of the types defined by the macro. |
This PR adds some convenience macros for defining strong types.
Background: #429 (comment)
tl;dr We want to avoid defining strong types as type aliases of
cuco::detail::strong_typeas this leads to a situation where all strong types with the same underlying value type are indistinguishable: