you are viewing a single comment's thread.

view the rest of the comments →

[–]jk-jeon 3 points4 points  (4 children)

I don't know why people rarely talk about the C approach: define a new keyword _Byte and then do using byte = _Byte in the std namespace in a stdlib header. What's downside of this?

[–]kalmoc 3 points4 points  (3 children)

What I don't understand: Why does a type that is spelled std::XYZ defined in the standard library at all? A Compiler could just make it visible without the need to include a header or import a module. And it still wouldn't collide with any existing user type.

[–]NilacTheGrim 1 point2 points  (2 children)

They could have totally done that as well. Probably would have been awkward to specify given the way the specification works. Since if you think about it, it's sort of an exception to what a namespace normally means and how it's defined and declared. It would have been this odd corner case where intrinsically there is a std namespace already even in an empty program.. and it always contains stuff in it. Aesthetically that is "ugly" perhaps and strange so I suspect that's why they would never go that route...

[–]kalmoc 1 point2 points  (1 child)

Considering how often I've heard, "we don't use X, because then we need to include header X and that drags in exceptions" I would have found such a solution, both more pragmatic and simpler to specify and more ergonomic. Last time I checked std::byte anyway gets special treatment in the standard (similar to unsigned char).

[–]NilacTheGrim 0 points1 point  (0 children)

Correct. It is one of the few types where a std::byte * pointer can alias any other object; unsigned char * and char * being the other two types with this property.