In CPP Reference it is stated that:
std::byteis a distinct type that implements the concept of byte as specified in the C++ language definition.Like char and unsigned char, it can be used to access raw memory occupied by other objects (object representation), but unlike those types, it is not a character type and is not an arithmetic type. A byte is only a collection of bits, and only bitwise operators are defined for it.
But that's not true: since it is an enumeration type, the compare operations (<, <=, >, >=, ==, !=) are also possible.
Is this intentional, e.g. to use std::byte also as a key for std::map, etc.?
Yes, it's intentional that
std::bytehas comparison operators. The proposal forstd::bytesays this:- P0298r3 A byte type definition
As you've pointed out, this allows using
std::byteas keys in containers. It also allows usingstd::bytein algorithms likestd::partition,std::sort,std::unique, etc., where equality or less-than comparison is needed.Note that the Common definitions library section in the C++ standard doesn't say much about
std::byte. It doesn't say that it's not meant to be comparable.Keep in mind that cppreference isn't normative, and is editable by anyone* without opening an account. There are numerous sections that are incomplete, and errors frequently make their way into the wiki. Most likely, the author forgot that
std::bytealso has comparison operators.* In fact, I've just edited the page myself, and it now says: