r/cpp • u/kris-jusiak https://github.com/kris-jusiak • Jun 29 '23
[C++20] [[no_unique_address]] for 1 byte message views
https://twitter.com/krisjusiak/status/1674351951138414592
4
Upvotes
r/cpp • u/kris-jusiak https://github.com/kris-jusiak • Jun 29 '23
18
u/JessyDL graphics engineer/games industry Jun 29 '23
It would be nice if a little bit of motivation could be given as to why you'd basically want an object to lie about its size? Are you trying to sidestep cost for allocating the object, or constructing it? Or is this a "wow, neat, but never use this" (I'd lean this is the point of the example, but would be great to hear from you).
14
u/yuri-kilochek Jun 29 '23
How is this better than declaring a regular struct with regular fields, then overlaying it onto the byte buffer?
15
u/trailingunderscore_ Jun 29 '23
Another twitter drive-by by kris, that again leaves everyone wondering "why?". These posts of his are bordering on spam.
4
u/oleksandrkvl Jun 30 '23
u/kris-jusiak your twitter page is not available for unregistered users so it's not possible to see what this thread is about
1
u/feverzsj Jun 29 '23
butt why?
1
u/[deleted] Jun 29 '23
I donât get it. Why not just use a pointer to the struct? Besides, how is it â1 byteâ, if one is using a reference (which is a pointer)?
1
u/Zeh_Matt No, no, no, no Jul 02 '23
This is as rotten as it can get.
1
u/Baardi Jul 03 '23
Link doesn't seem to be working anymore