rs-core

Core utilities


Project maintained by CaptainCrowbar Hosted on GitHub Pages — Theme by mattgraham

Global Definitions

Core utility library by Ross Smith

#include "rs-core/global.hpp"
namespace RS;

Contents

Notes

This header also includes "rs-core/log.hpp" to allow users to easily add logging in arbitrary locations without dependency changes.

Concepts

Primitive concepts

template <typename T> concept ByteType;

Matches the types that can alias a byte of memory: char, signed char, unsigned char, char8_t, std::byte.

template <typename T> concept Character;

Matches any standard character type: char, char8_t, char16_t, char32_t, wchar_t.

template <typename T> concept Reference;
template <typename T> concept MutableReference;
template <typename T> concept ConstReference;
template <typename T> concept NonReference;

Reference type concepts. The names should be self-explanatory.

Arithmetic concepts

template <typename T> concept Integral;
template <typename T> concept SignedIntegral;
template <typename T> concept UnsignedIntegral;
template <typename T> concept FloatingPoint;
template <typename T> concept FixedPointArithmetic;
template <typename T> concept RationalArithmetic;
template <typename T> concept Arithmetic;

Integral, SignedIntegral, UnsignedIntegral, and FloatingPoint match the same types as the similarly named standard library concepts, as well as any type that has a specialization of numeric_limits with the appropriate values for is_integer and is_signed.

The FixedPointArithmetic and RationalArithmetic concepts are based purely on the type’s specialization of numeric_limits, checking for additional custom constants, is_fixed_point and is_rational. Any type that matches either of these is excluded from matching any of the integer or floating point concepts even if their properties would otherwise qualify them. It is legal for a type to match both of these.

The Arithmetic concept matches any type that matches any of the other concepts listed here.

The bool type, and any type matching Character, are excluded from all of these concepts.

Range concepts

template <typename T> concept InputSpan =
    [readable contiguous range]
    && [value type matches ByteType];
template <typename T> concept OutputSpan =
    [writable contiguous range]
    && [value type matches ByteType];
template <typename T> concept OutputBuffer =
    OutputSpan
    && [resize(number, value) member function];

Byte-oriented ranges and containers used as I/O buffers.

Constants

constexpr std::string_view ascii_whitespace = "\t\n\r ";
constexpr std::uint8_t max8 = [maximum value of a uint8_t];
constexpr std::uint16_t max16 = [maximum value of a uint16_t];
constexpr std::uint32_t max32 = [maximum value of a uint32_t];
constexpr std::uint64_t max64 = [maximum value of a uint64_t];
constexpr std::size_t npos = [maximum value of a size_t];

Defined for convenience.

Metaprogramming utilities

template <typename> constexpr bool dependent_false = false;

Used when the equivalent of static_assert(false) is needed in a dependent context.

template <typename T> concept MaybeNontypeParameter;

Checks whether a type can be used as a non-type template parameter.