video:
https://www.youtube.com/watch?v=jLdSjh8oqmE
library:
https://sourceforge.net/p/opaque-typedef/wiki/Home/#opaque-typedef-library
Reference:
Toward Opaque Typedefs for C++1Y, v2 (PDF)
[C++][NOTE][ORIGINAL] Strong typedef
Microprocessors have kinds of addresses:
What kind of address am I talking about?
Opaque typedef
Idea:
code:
Merit:
https://www.youtube.com/watch?v=jLdSjh8oqmE
library:
https://sourceforge.net/p/opaque-typedef/wiki/Home/#opaque-typedef-library
Reference:
Toward Opaque Typedefs for C++1Y, v2 (PDF)
[C++][NOTE][ORIGINAL] Strong typedef
Microprocessors have kinds of addresses:
- Virtual address
- Linear address
- Guest physical address
- Host physical address
- DDR address
What kind of address am I talking about?
Opaque typedef
Idea:
- Wrap a variable of some type in a new type
- Mimic the interface of the original type, but using the new type
code:
struct linaddr : numeric_typedef<uint64_t, linaddr> { using base = numeric_typedef<uint64_t, linaddr>; using base::base; }
Merit:
- Safer interfaces by removing implicit convertibility
- Makes overloading on the new type possible
- Turn semantic bugs into compile time errors
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.