C++20 module

C++ 20 language and library features backported to C++17.

Files

file assume_aligned.h
Contains the definition of muu::assume_aligned().
file bit.h
Bit manipulation functions. C++20's <bit> with extra steps.
file bit_cast.h
Contains the definition of muu::bit_cast().
file bit_ceil.h
Contains the definition of muu::bit_ceil().
file bit_floor.h
Contains the definition of muu::bit_floor().
file is_constant_evaluated.h
Contains the definitions of muu::is_constant_evaluated(), MUU_IF_CONSTEVAL and MUU_IF_RUNTIME.
file source_location.h
Contains the definition of muu::source_location.

Classes

class muu::source_location
A backport of C++20's std::source_location.
template <typename T, size_t Extent = dynamic_extent, size_t Alignment = 0>
class muu::span
A non-owning view of contiguous elements.

Typedefs

template <size_t Alignment>
using aligned_byte_span = span<std::byte, dynamic_extent, Alignment>
Convenience alias for span<std::byte, dynamic_extent, Alignment>.
using byte_span = span<std::byte>
Convenience alias for span<std::byte>.
using const_byte_span = span<const std::byte>
Convenience alias for span<const std::byte>.
template <typename T, size_t Extent = dynamic_extent, size_t Alignment = 0>
using const_span = span<const T, Extent, Alignment>
Convenience alias for span<const T, Extent>.

Functions

template <typename T, size_t E, size_t A>
auto as_bytes(span<T, E, A> s) -> span<const std::byte, impl::as_bytes_extent<T, E>> noexcept
Reinterprets a span as an immutable view of the underlying bytes.
template <typename T, size_t E, size_t A>
auto as_writable_bytes(span<T, E, A> s) -> span<std::byte, impl::as_bytes_extent<T, E>> noexcept
Reinterprets a span as a view of the underlying bytes.

Typedef documentation

#include <muu/span.h>
template <size_t Alignment>
using aligned_byte_span = span<std::byte, dynamic_extent, Alignment>

Convenience alias for span<std::byte, dynamic_extent, Alignment>.

using byte_span = span<std::byte>
#include <muu/span.h>

Convenience alias for span<std::byte>.

using const_byte_span = span<const std::byte>
#include <muu/span.h>

Convenience alias for span<const std::byte>.

#include <muu/span.h>
template <typename T, size_t Extent = dynamic_extent, size_t Alignment = 0>
using const_span = span<const T, Extent, Alignment>

Convenience alias for span<const T, Extent>.

Function documentation

#include <muu/span.h>
template <typename T, size_t E, size_t A>
span<const std::byte, impl::as_bytes_extent<T, E>> as_bytes(span<T, E, A> s) noexcept

Reinterprets a span as an immutable view of the underlying bytes.

Equivalent to C++20's std::as_bytes.

#include <muu/span.h>
template <typename T, size_t E, size_t A>
span<std::byte, impl::as_bytes_extent<T, E>> as_writable_bytes(span<T, E, A> s) noexcept

Reinterprets a span as a view of the underlying bytes.

Equivalent to C++20's std::as_writable_bytes.