|
|
|
|
|
by nhaehnle
342 days ago
|
|
> don't have infinite different copies of the int64_t type You can make some, though! Basically, the idea is to define a class template NoAlias<T, Tag> that contains a single value of type T. Implement operators etc. to make the type useful in practice for working with the wrapped value. Type-based alias rules mean that an access to the value wrapped in NoAlias<int64_t, Tag1> can never alias a value wrapped in NoAlias<int64_t, Tag2>. (Tag1 and Tag2 can just be forward-declared structs that are never defined.) One time, I even encountered a situation where this was mildly useful. |
|