Skip to content

Latest commit

 

History

History
20 lines (12 loc) · 556 Bytes

casts.rst

File metadata and controls

20 lines (12 loc) · 556 Bytes

casts

Source code

A handful of handy casts.

template <class To, class From> To tl::bit_cast (From const& from)

Casts the bit representation of from to a To. Use this instead of type punning through a union or reinterpret_cast. Essentially does: :

To to;
std::memcpy(&to, &from, sizeof(to));

template <class E> auto underlying_cast (E e)

Casts an enumerator value to its underlying type.

SFINAE-friendly.