cxxomfort  rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
Classes | Namespaces | Functions
bit.hpp File Reference

Implementations and completion of names tied to bit. More...

Classes

struct  count_l_0_t< U, u >
 Defines member value with the number of lefmost 0 s in u . More...
 
struct  leftmost_1< U, u >
 Defines member value with the position of the leftmost 1 bit in u . More...
 

Namespaces

 cxxomfort
 Namespace of the cxxomfort library.
 
 cxxomfort::fix
 Fixes for implementation issues in std.
 
 cxxomfort::cxxostd
 Backports made available by cxxomfort.
 

Functions

template<typename To , typename From >
constexpr To bit_cast (From const &from)
 Reinterpret the bit pattern content of an object (C++20) -. More...
 
template<typename U >
constexpr U bit_width (U u) noexcept
 
template<typename U >
constexpr U bit_floor (U u) noexcept
 
template<typename U >
constexpr U bit_ceil (U u) noexcept
 
template<typename U >
constexpr int popcount (U u) noexcept
 

Detailed Description

Implementations and completion of names tied to bit.

<bit>:

Function Documentation

◆ bit_cast()

constexpr To std::bit_cast ( From const &  from)

Reinterpret the bit pattern content of an object (C++20) -.

C++20 Backports:
Reinterpret the bit pattern of an object as an object of a different type.
<bit>:
Reinterpret the bit pattern of a type.
See also
numeric/bit_cast @ cppreference
Precondition
From , To need both to be trivially copyable.
In C++<14 in cxxomfort's implementation, To needs to also have a trivial default constructor.