Header lexy/callback/bit_cast.hpp

Callback lexy::bit_cast

namespace lexy
    template <typename T>
    constexpr callback auto bit_cast;

A callback that calls std::bit_cast.

It requires that T is trivially copyable. It accepts any type that is also trivially copyable and has the same size as T. It then converts the argument to T by reinterpreting the bits.

If std::bit_cast is not available, it is emulated. This might make the callback non-constexpr and require that T is in addition default constructible.