Inidicate that code blocks contain C++#206
Conversation
|
This code requires more updates:
This is not true anymore from C++17. |
colin-home
left a comment
There was a problem hiding this comment.
Approved. Thanks for contributing!
Regarding the comment about the byte type, I could find no reference to a fundamental type named byte in either the C++17 or draft C++20 standard. There's a library type named std::byte in C++20, but it's not part of the underlying language.
|
Do I understand correctly that comment to be tongue in cheek?
In light of Your answer then this part is not true :
But also please consider that this document http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0298r3.pdf says:
|
|
The last draft standard for C++17 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4640.pdf A search for |
|
There's now a std::byte is in C++20 as part of <cstddef>, in section 21.2.1, along with a handy set of operators. I'd certainly recommend its use in any new code that turns on the /std:c++latest switch. However, my search of the C++17 draft standard you linked reports no hits for std::byte at all. And even Neil's paper that you refer to is basically showing how a library implementation is good enough to act as if it were part of the language - but specifically states that it can't be part the language, or at least, not under that name. Far too much code exists that defines byte either with the preprocessor or as a typedef or alias UDT (usually as unsigned char), and it would all break. That Would Be Bad. |
|
Ah, I must apologize, I now see that std::byte did make it into the final C++17 standard after all. I should have looked at that, instead of the earlier drafts. You are right, it does get mentioned in a few places, but my reading of the standard indicates that these references to std::byte don't require any special compiler behavior, and should work for any UDT defined the same way. It's still a library type, not built-in. And you can get it with /std:c++17 as well as /std:c++latest, which is handy. |
No description provided.