C++20 added the function std::bit_cast to the standard library. While the result of it is defined, simply reinterpreting the bytes making up the object-representation, there are actually no defined results (beyond the identity case, which is simply copy-constructing the result from the input). This seeks to add limitations on the results of std::bit_cast, which are believed to be reasonable, and may be expected in practice.
Reflexive:
(Included for completeness)
* If r is an expression of type T, the expression std::bit_cast<T>(r) shall be equivalent to copy constructing the result from r, except that the expression treats copy constructors which are defined as deleted as though they were defined as default instead, and does not call move constructors even if r is an rvalue.
Enumerations and Integral types:
* If r is an expression of a (potentially cv-qualified) integral type other than bool or an enumeration type, and U is a (potentially cv-qualified) integral type other than bool or an enumeration type, the expression std::bit_cast<U>(r), if well formed, shall be an equivalent expression to static_cast<U>(r)
Pointer types:
* If r is an expression of type (potentially cv-qualified) pointer to void or pointer to a character type, and U such a type, let P be the same pointer type as the type or r, but with the same cv-qualifiers (ignoring top-level cv-qualifiers) as U, the expression std::bit_cast<U>(r) shall be well-formed and shall be an equivalent expression as reinterpret_cast<U>(const_cast<P>(r))
* If r is an expression of type T*, and U is the same type as T ignoring top level cv-qualifiers, then the expression std::bit_cast<U>(r) shall be well-formed, and shall be an equivalent expression to const_cast<U*>(r)
Pointer-interconvertible:
* If r is an (potentially const-qualified) lvalue, designating an object a, and U is a type, such that (ignoring all top-level cv-qualifiers), there is an object of type U, b, that is pointer-interconvertible with a, then the expression std::bit_cast<U>(r), if well formed, is equivalent to copy-constructing the result from a const-qualified lvalue designating b.
Union:
* If r is an expression of type T, and U is a union type which has at least one member of type T which is not a bitfield, if the expression std::bit_cast<U>(r), if well-formed, shall yield a union where the active member is the member of type T and is initialized as though by std::bit_cast<T>(r). If there are multiple such members, the active member is the first such member accessed by the program, or otherwise an unspecified member of that type. If the union has a member of a reference type, the behaviour is undefined.
reference_wrapper:
* If r is an expression of type std::reference_wrapper<T>and U is (possibly differently cv-qualified) T, then the expression std::bit_cast<U*>(r), shall be well-formed and an equivalent expression to const_cast<U*>(std::addressof(static_cast<T&>(r)))
* If r is an expression of type T*, which points to an object, and U is (possibly differently cv-qualified) T, then the expression std::bit_cast<std::reference_wrapper<U>>(r) shall be well-formed, and an equivalent expression to std::ref(*const_cast<U*>(r)). If r does not point to an object, the behaviour is undefined. If T is an incomplete type other than (possibly cv-qualified) void or an array of unknown bound, the expression treats T as though it was completed. If T is an array of unknown bound, the expression treats T as though it were an array with length 1.