OGLplus  (0.59.0) a C++ wrapper for rendering APIs

Memory utilities

Classes

class  eagine::memory::basic_address< IsConst >
 Class for handling memory addresses as integer values. More...
 
class  eagine::memory::aligned_block< Size >
 Class containing store of the specified size convertible to block. More...
 
class  eagine::memory::owned_block
 Specialization of block indicating byte span ownership. More...
 
class  eagine::memory::block_owner
 Base class for classes that act as memory block owners. More...
 
class  eagine::memory::buffer
 Reallocatable owning byte buffer. More...
 
class  eagine::memory::buffer_pool
 Class storing multiple reusable memory buffer instances. More...
 
class  eagine::memory::basic_offset_ptr< Pointee, OffsetType >
 Basic offset pointer class template. More...
 
class  eagine::memory::basic_split_span< ValueType, Pointer, SizeType >
 Template for classes representing a memory span split in two parts. More...
 

Typedefs

using eagine::memory::const_address = basic_address< true >
 Type alias for const memory address values.
 
using eagine::memory::address = basic_address< false >
 Type alias for non-const memory address values.
 
using eagine::memory::block = basic_block< false >
 Alias for non-const byte memory span. More...
 
using eagine::memory::const_block = basic_block< true >
 Alias for const byte memory span. More...
 
template<typename Pointee >
using eagine::memory::offset_ptr = basic_offset_ptr< Pointee, std::ptrdiff_t >
 Default type alias for basic offset pointer.
 
template<typename Pointee >
using eagine::memory::short_offset_ptr = basic_offset_ptr< Pointee, short >
 Type alias for basic offset pointer with short offset.
 
template<typename T , typename O = span_size_t, typename S = span_size_t>
using eagine::memory::basic_offset_span = memory::basic_span< T, basic_offset_ptr< T, O >, S >
 Basic alias for basic_span with basic_offset_pointer.
 
template<typename T >
using eagine::memory::offset_span = basic_offset_span< T >
 Default alias for basic_offset_span.
 
template<typename T , typename S = span_size_t>
using eagine::memory::span = basic_span< T, T *, S >
 Default alias for basic memory spans with native pointer type.
 
template<typename T >
using eagine::memory::span_if_mutable = std::enable_if_t<!std::is_const_v< T >, span< T > >
 Alias for span<T> if T is mutable type. Ill defined otherwise.
 
template<typename T >
using eagine::memory::const_span = span< std::add_const_t< T > >
 Alias for spans with const element type.
 
using eagine::memory::split_block = basic_split_block< false >
 Alias for non-const split blocks.
 
using eagine::memory::const_split_block = basic_split_block< true >
 Alias for const split blocks.
 

Functions

template<typename T >
static constexpr auto eagine::memory::as_address (T *addr) noexcept
 Casts a pointer to basic_address.
 
static constexpr auto eagine::memory::misalignment (const_address addr, span_size_t alignment) noexcept
 Returns the misalignment of a memory address to the specified alignment.
 
static constexpr auto eagine::memory::misalignment (const void *ptr, span_size_t alignment) noexcept
 Returns the misalignment of a pointer to the specified alignment.
 
static constexpr auto eagine::memory::is_aligned_to (const_address addr, span_size_t alignment) noexcept
 Indicates if a memory address aligned to the specified alignment.
 
static constexpr auto eagine::memory::is_aligned_to (const void *ptr, span_size_t alignment) noexcept
 Indicates if a pointer is aligned to the specified alignment.
 
template<typename T >
static constexpr auto eagine::memory::is_aligned_as (const_address addr, type_identity< T > tid={}) noexcept
 Indicates if a memory address aligned as the specified type T.
 
template<bool IsConst>
static constexpr auto eagine::memory::align_up (basic_address< IsConst > addr, span_size_t align, span_size_t max) noexcept -> basic_address< IsConst >
 Aligns a memory address up to the specified alignment. More...
 
template<bool IsConst>
static constexpr auto eagine::memory::align_down (basic_address< IsConst > addr, span_size_t align, span_size_t max) noexcept -> basic_address< IsConst >
 Aligns a memory address down to the specified alignment. More...
 
template<bool IsConst>
static constexpr auto eagine::memory::align_down (basic_address< IsConst > addr, span_size_t align) noexcept
 Aligns a memory address down to the specified alignment.
 
static auto eagine::memory::align_down (const byte *ptr, span_size_t align) -> const byte *
 Aligns a byte pointer down to the specified alignment.
 
template<typename T >
static constexpr auto eagine::memory::align_up_to (basic_address< std::is_const_v< T >> addr, type_identity< T >={}, span_size_t align=span_align_of< T >(), span_size_t max=span_size_of< T >()) noexcept
 Aligns a memory address up to the required alignment of type T. More...
 
template<typename T >
static constexpr auto eagine::memory::align_down_to (basic_address< std::is_const_v< T >> addr, type_identity< T >={}, span_size_t align=span_align_of< T >(), span_size_t max=span_size_of< T >()) noexcept
 Aligns a memory address down to the required alignment of type T. More...
 
static constexpr auto eagine::memory::misalignment (span_size_t addr, span_size_t alignment) noexcept -> span_size_t
 Calculates basic numeric address misalignment.
 
static constexpr auto eagine::memory::misalignment (std::nullptr_t, span_size_t) noexcept -> span_size_t
 Calculates basic numeric address misalignment.
 
static constexpr auto eagine::memory::is_aligned_to (span_size_t addr, span_size_t algn) noexcept
 Indicates if a basic numeric address is aligned.
 
static constexpr auto eagine::memory::is_aligned_to (std::nullptr_t, span_size_t) noexcept
 Indicates if a basic numeric address is aligned.
 
template<typename T >
static constexpr auto eagine::memory::is_aligned_as (span_size_t addr, type_identity< T >={}) noexcept
 Indicates if a basic numeric address is aligned to alignment of type T.
 
template<typename T , typename P , typename S >
static constexpr auto eagine::memory::as_bytes (basic_span< T, P, S > spn) noexcept -> basic_block< std::is_const_v< T >>
 Converts a span into a basic_block. More...
 
static constexpr auto eagine::memory::as_chars (block blk) noexcept
 Converts a block into a span of characters. More...
 
static constexpr auto eagine::memory::as_chars (const_block blk) noexcept
 Converts a block into a span of characters. More...
 
static auto eagine::memory::copy (const_block source, block dest) -> block
 Copies the content of source block to destination block. More...
 
static auto eagine::memory::copy_into (const_block source, buffer &dest) -> block
 Copies the content of source block to destination buffer. More...
 
template<typename P , typename O >
static constexpr auto eagine::memory::as_address (basic_offset_ptr< P, O > op) noexcept -> basic_address< std::is_const_v< P >>
 Converts basic_offset_ptr into basic_address.
 
template<typename T , typename P , typename S >
static constexpr auto eagine::memory::relative (basic_span< T, P, S > spn) noexcept -> basic_span< T, basic_offset_ptr< T, std::make_signed_t< S >>, S >
 Converts argument to span using an offset pointer type. More...
 
template<typename T , typename P , typename S >
static constexpr auto eagine::memory::absolute (basic_span< T, P, S > spn) noexcept -> basic_span< T, T *, S >
 Converts argument to span using a native pointer type. More...
 
template<typename T >
static constexpr auto eagine::memory::view_one (const T &value) noexcept -> const_span< T >
 Creates a single-const-element view over the specified value.
 
template<typename T >
static constexpr auto eagine::memory::cover_one (T &value) noexcept -> span_if_mutable< T >
 Creates a single-element mutable span over the specified value.
 
template<typename T >
static constexpr auto eagine::memory::view_one (const T *pointer) noexcept -> const_span< T >
 Creates a single-const-element view from the specified pointer.
 
template<typename T >
static constexpr auto eagine::memory::cover_one (T *pointer) noexcept -> span_if_mutable< T >
 Creates a single-element mutable span from the specified pointer.
 
template<typename T , typename S >
static constexpr auto eagine::memory::view (T *addr, S size) noexcept -> const_span< T >
 Creates a view starting at the specified pointer and specified length.
 
template<typename T , typename S >
static constexpr auto eagine::memory::cover (T *addr, S size) noexcept -> span_if_mutable< T >
 Creates a span starting at the specified pointer and specified length.
 
template<typename T , typename S >
static constexpr auto eagine::memory::view (const_address addr, S size) noexcept -> const_span< T >
 Creates a view starting at the specified address and specified length.
 
template<typename T , typename S >
static constexpr auto eagine::memory::cover (address addr, S size) noexcept -> span_if_mutable< T >
 Creates a span starting at the specified address and specified length.
 
template<typename T , std::size_t N>
static constexpr auto eagine::memory::view (const T(&array)[N]) noexcept -> const_span< T >
 Creates a const view over the specified fixed-size array.
 
template<typename T , std::size_t N>
static constexpr auto eagine::memory::cover (T(&array)[N]) noexcept -> span_if_mutable< T >
 Creates a mutable span covering the specified fixed-size array.
 
template<typename T >
static constexpr auto eagine::memory::view (std::initializer_list< T > il) noexcept -> const_span< T >
 Creates a const view over the specified initializer list.
 
template<typename C , typename = std::enable_if_t<has_span_data_member_v<C> && has_span_size_member_v<C>>>
static constexpr auto eagine::memory::view (const C &container) noexcept
 Creates a const view over a compatible contiguous container.
 
template<typename C , typename = std::enable_if_t<has_span_data_member_v<C> && has_span_size_member_v<C>>>
static constexpr auto eagine::memory::cover (C &container) noexcept
 Creates a mutable span covering a compatible contiguous container.
 
template<typename T , typename B , typename P , typename S >
static constexpr auto eagine::memory::accomodate (basic_span< B, P, S > blk, type_identity< T > tid={}) noexcept -> basic_span< std::add_const_t< T >, rebind_pointer_t< P, T >, S >
 Returns a span, rebinding the element type (typically from basic_block). More...
 
template<typename T , typename P , typename S >
static constexpr auto eagine::memory::extract (basic_span< T, P, S > spn) noexcept -> T &
 Overload of extract for spans. Returns the first element,. More...
 
template<typename T , typename P , typename S >
static constexpr auto eagine::memory::extract_or (basic_span< T, P, S > spn, T &fallback) noexcept -> T &
 Overload of extract_or for spans. Returns the first element,.
 
template<typename T , typename P , typename S , typename F >
static constexpr auto eagine::memory::extract_or (basic_span< T, P, S > spn, F &&fallback) -> std::enable_if_t< std::is_convertible_v< F, T >, T >
 Overload of extract_or for spans. Returns the first element,.
 
template<typename T , typename P , typename S , typename I , typename L >
static constexpr auto eagine::memory::slice (basic_span< T, P, S > s, I i, L l) noexcept -> basic_span< T, P, S >
 Returns a slice of span starting at specified index with specified length. More...
 
template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::skip (basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
 Skips a specified count of elements from the front of a span. More...
 
template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::snip (basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
 Snips a specified count of elements from the back of a span. More...
 
template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::shrink (basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
 Shrinks a span by removing a specified count of elements from both sides. More...
 
template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::head (basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
 Returns the first l elements from the front of a span. More...
 
template<typename Ts , typename Ps , typename Ss , typename Tl , typename Pl , typename Sl >
static constexpr auto eagine::memory::head (basic_span< Ts, Ps, Ss > s, basic_span< Tl, Pl, Sl > l) noexcept -> basic_span< Ts, Ps, Ss >
 Returns the head of s l.size() elements long. More...
 
template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::tail (basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
 Returns the last l elements from the back of a span. More...
 
template<typename Ts , typename Ps , typename Ss , typename Tl , typename Pl , typename Sl >
static constexpr auto eagine::memory::tail (basic_span< Ts, Ps, Ss > s, basic_span< Tl, Pl, Sl > l) noexcept -> basic_span< Ts, Ps, Ss >
 Returns the tail of s l.size() elements long. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::starts_with (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > with) -> bool
 Indicates if span spn starts with the content of with. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::ends_with (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > with) -> bool
 Indicates if span spn ends with the content of with. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::strip_prefix (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > prefix) -> basic_span< T1, P1, S1 >
 Strips the specified prefix from a span. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::strip_suffix (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > suffix) -> basic_span< T1, P1, S1 >
 Strips the specified suffix from a span. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::contains (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) noexcept -> S1
 Indicates if a span contains the contents of what. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::find_position (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) noexcept -> optionally_valid< S1 >
 Finds the position of the first occurrence of what in a span. More...
 
template<typename T , typename P , typename S , typename E >
static constexpr auto eagine::memory::find_element (basic_span< T, P, S > spn, E what) noexcept -> optionally_valid< S >
 Finds the position of the first occurrence of what in a span. More...
 
template<typename T , typename P , typename S , typename F >
static constexpr auto eagine::memory::find_element_if (basic_span< T, P, S > spn, F predicate) noexcept -> optionally_valid< S >
 Finds the position of the first element satisfying predicate in a span. More...
 
template<typename T , typename P , typename S , typename Predicate >
static constexpr auto eagine::memory::skip_until (basic_span< T, P, S > spn, Predicate predicate) noexcept -> basic_span< T, P, S >
 Skips the elements from the front of a span until predicate is satisfied. More...
 
template<typename T , typename P , typename S , typename Predicate >
static constexpr auto eagine::memory::take_until (basic_span< T, P, S > spn, Predicate predicate) noexcept -> basic_span< T, P, S >
 Takes the elements from the front of a span until predicate is satisfied. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::reverse_find_position (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) noexcept -> optionally_valid< S1 >
 Finds the position of the last occurrence of what in a span. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::find (basic_span< T1, P1, S1 > where, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
 Finds the position of the last occurrence of what in a span. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_before (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
 Returns a slice of span before the first occurrence of what. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_after (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
 Returns a slice of span after the first occurrence of what. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::split_by_first (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> std::tuple< basic_span< T1, P1, S1 >, basic_span< T1, P1, S1 >>
 Splits a span by the first occurrence of what (before and after, what) More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_before_last (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
 Returns a slice of span before the last occurrence of what. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_after_last (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
 Returns a slice of span after the last occurrence of what. More...
 
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::split_by_last (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> std::tuple< basic_span< T1, P1, S1 >, basic_span< T1, P1, S1 >>
 Splits a span by the last occurrence of what (before and after, what) More...
 
template<typename T , typename P , typename S , typename B >
static auto eagine::memory::slice_inside_brackets (basic_span< T, P, S > spn, B left, B right) noexcept -> basic_span< T, P, S >
 Returns a slice of span within a pair of brackets. More...
 
template<typename TF , typename PF , typename SF , typename TT , typename PT , typename ST >
static auto eagine::memory::copy (basic_span< TF, PF, SF > from, basic_span< TT, PT, ST > to) -> basic_span< TT, PT, ST >
 Copies the elements from one span to another compatible span. More...
 
template<typename T , typename P , typename S , typename V >
static auto eagine::memory::fill (basic_span< T, P, S > spn, const V &v) -> basic_span< T, P, S >
 Fills a span with copies of the specified value. More...
 
template<typename T , typename P , typename S >
static auto eagine::memory::zero (basic_span< T, P, S > spn) -> std::enable_if_t< std::is_integral_v< T >||std::is_floating_point_v< T >, basic_span< T, P, S >>
 Fills a span with zero value of type T. More...
 
template<typename T , typename P , typename S >
static auto eagine::memory::reverse (basic_span< T, P, S > spn) -> basic_span< T, P, S >
 Reverses the elements in a span. More...
 
template<typename T , typename P , typename S , typename Transform >
static auto eagine::memory::transform (basic_span< T, P, S > spn, Transform function) -> basic_span< T, P, S >
 Transforms the elements of a span with a function. More...
 
template<typename T , typename P , typename S , typename Generator >
static auto eagine::memory::generate (basic_span< T, P, S > spn, Generator gen) -> basic_span< T, P, S >
 Fills a span with elements generated by a generator callable. More...
 
template<typename T , typename P , typename S , typename RandGen >
static auto eagine::memory::shuffle (basic_span< T, P, S > spn, RandGen rg) -> basic_span< T, P, S >
 Shuffles the elements of a span. More...
 
template<typename T , typename P , typename S >
static auto eagine::memory::sort (basic_span< T, P, S > spn) -> basic_span< T, P, S >
 Sorts the elements of a span. More...
 
template<typename T , typename P , typename S , typename Compare >
static auto eagine::memory::sort (basic_span< T, P, S > spn, Compare compare) -> basic_span< T, P, S >
 Sorts the elements of a span according to compare. More...
 
template<typename T , typename P , typename S , typename I , typename PI , typename SI , typename Compare >
static auto eagine::memory::make_index (basic_span< T, P, S > spn, basic_span< I, PI, SI > idx, Compare compare) -> bool
 Makes the index of a span according to compare, into another span. More...
 
template<typename T , typename P , typename S , typename I , typename PI , typename SI >
static auto eagine::memory::make_index (basic_span< T, P, S > spn, basic_span< I, PI, SI > idx) -> bool
 Makes the index of a span, into another span. More...
 
template<typename T , typename P , typename S >
static auto eagine::memory::is_sorted (basic_span< T, P, S > spn) -> bool
 Tests if the elements in a span are sorted. More...
 
template<typename T , typename P , typename S , typename Compare >
static auto eagine::memory::is_sorted (basic_span< T, P, S > spn, Compare compare) -> bool
 Tests if the elements in a span are sorted according to compare. More...
 
template<typename T , typename P , typename S , typename Output >
static auto list_to_stream (Output &out, memory::basic_span< T, P, S > s) -> Output &
 Helper function for pretty-printing spans as lists into output streams. More...
 
template<typename Input , typename T , typename P , typename S >
static auto read_from_stream (Input &in, memory::basic_span< T, P, S > s) -> auto &
 Helper function for raw-reading spans from output streams. More...
 
template<typename Output , typename T , typename P , typename S >
static auto write_to_stream (Output &out, memory::basic_span< T, P, S > s) -> auto &
 Helper function for raw-reading spans into output streams. More...
 
template<typename T , typename P , typename S >
static auto operator<< (std::ostream &out, memory::basic_span< T, P, S > s) -> std::enable_if_t<!std::is_same_v< std::remove_const_t< T >, char >, std::ostream & >
 Operator for printing generic element spans into output streams. More...
 
template<typename T , typename P , typename S >
static auto make_span_getter (span_size_t &i, memory::basic_span< T, P, S > spn)
 Makes a callable that returns consecutive span elements starting at i. More...
 
template<typename T , typename P , typename S , typename Transform >
static auto make_span_getter (span_size_t &i, memory::basic_span< T, P, S > spn, Transform transform)
 Makes a callable getting consecutive, transformed span elements starting at i. More...
 
template<typename T , typename P , typename S >
static auto make_span_putter (span_size_t &i, memory::basic_span< T, P, S > spn)
 Makes a callable setting consecutive elements of a span starting at i. More...
 
template<typename T , typename P , typename S , typename Transform >
static auto make_span_putter (span_size_t &i, memory::basic_span< T, P, S > spn, Transform transform)
 Makes a callable setting consecutive elements of a span starting at i. More...
 

Detailed Description

Typedef Documentation

◆ block

using eagine::memory::block = typedef basic_block<false>

Alias for non-const byte memory span.

See also
buffer
Examples
eagine/c_api_wrap.cpp.

◆ const_block

Function Documentation

◆ absolute()

template<typename T , typename P , typename S >
static constexpr auto eagine::memory::absolute ( basic_span< T, P, S >  spn) -> basic_span<T, T*, S>
staticconstexprnoexcept

Converts argument to span using a native pointer type.

See also
relative

Referenced by eagine::memory::basic_span< const gl_types::ubyte_type >::operator<<().

◆ accomodate()

template<typename T , typename B , typename P , typename S >
static constexpr auto eagine::memory::accomodate ( basic_span< B, P, S >  blk,
type_identity< T >  tid = {} 
) -> basic_span<std::add_const_t<T>, rebind_pointer_t<P, T>, S>
staticconstexprnoexcept

Returns a span, rebinding the element type (typically from basic_block).

See also
as_bytes
as_chars

◆ align_down()

template<bool IsConst>
static constexpr auto eagine::memory::align_down ( basic_address< IsConst >  addr,
span_size_t  align,
span_size_t  max 
) -> basic_address<IsConst>
staticconstexprnoexcept

Aligns a memory address down to the specified alignment.

Parameters
maxThe maximum byte offset that can be applied to the address.

◆ align_down_to()

template<typename T >
static constexpr auto eagine::memory::align_down_to ( basic_address< std::is_const_v< T >>  addr,
type_identity< T >  = {},
span_size_t  align = span_align_of<T>(),
span_size_t  max = span_size_of<T>() 
)
staticconstexprnoexcept

Aligns a memory address down to the required alignment of type T.

Parameters
maxThe maximum byte offset that can be applied to the address.

◆ align_up()

template<bool IsConst>
static constexpr auto eagine::memory::align_up ( basic_address< IsConst >  addr,
span_size_t  align,
span_size_t  max 
) -> basic_address<IsConst>
staticconstexprnoexcept

Aligns a memory address up to the specified alignment.

Parameters
maxThe maximum byte offset that can be applied to the address.

◆ align_up_to()

template<typename T >
static constexpr auto eagine::memory::align_up_to ( basic_address< std::is_const_v< T >>  addr,
type_identity< T >  = {},
span_size_t  align = span_align_of<T>(),
span_size_t  max = span_size_of<T>() 
)
staticconstexprnoexcept

Aligns a memory address up to the required alignment of type T.

Parameters
maxThe maximum byte offset that can be applied to the address.

◆ as_bytes()

◆ as_chars() [1/2]

◆ as_chars() [2/2]

static constexpr auto eagine::memory::as_chars ( const_block  blk)
staticconstexprnoexcept

Converts a block into a span of characters.

See also
accomodate
as_bytes

◆ contains()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::contains ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> S1
staticconstexprnoexcept

Indicates if a span contains the contents of what.

See also
starts_with
ends_with

◆ copy() [1/2]

template<typename TF , typename PF , typename SF , typename TT , typename PT , typename ST >
static auto eagine::memory::copy ( basic_span< TF, PF, SF >  from,
basic_span< TT, PT, ST >  to 
) -> basic_span<TT, PT, ST>
inlinestatic

Copies the elements from one span to another compatible span.

See also
fill
zero
generate

Referenced by eagine::memory::copy().

◆ copy() [2/2]

static auto eagine::memory::copy ( const_block  source,
block  dest 
) -> block
inlinestatic

Copies the content of source block to destination block.

See also
const_block
block

Referenced by eagine::memory::copy(), eagine::memory::copy_into(), and eagine::istream_data_source::pop().

◆ copy_into()

static auto eagine::memory::copy_into ( const_block  source,
buffer dest 
) -> block
inlinestatic

Copies the content of source block to destination buffer.

See also
const_block
buffer

Referenced by eagine::msgbus::stored_message::store_content(), and eagine::embedded_resource::unpack().

◆ ends_with()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::ends_with ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  with 
) -> bool
staticconstexpr

Indicates if span spn ends with the content of with.

See also
starts_with
contains
strip_suffix

Referenced by eagine::program_arg::ends_with(), and eagine::memory::strip_suffix().

◆ extract()

template<typename T , typename P , typename S >
static constexpr auto eagine::memory::extract ( basic_span< T, P, S >  spn) -> T&
staticconstexprnoexcept

Overload of extract for spans. Returns the first element,.

Precondition
spn.size() >= 1

◆ fill()

template<typename T , typename P , typename S , typename V >
static auto eagine::memory::fill ( basic_span< T, P, S >  spn,
const V &  v 
) -> basic_span<T, P, S>
inlinestatic

Fills a span with copies of the specified value.

See also
copy
zero
generate
Examples
application/028_compute_particles/resources.cpp.

Referenced by eagine::memory::zero().

◆ find()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::find ( basic_span< T1, P1, S1 >  where,
basic_span< T2, P2, S2 >  what 
) -> basic_span<T1, P1, S1>
inlinestatic

Finds the position of the last occurrence of what in a span.

See also
find_element
find_element_if
find_position
Examples
eagine/dyn_lib_lookup.cpp, eagine/message_bus/006_ping.cpp, eagine/message_bus/007_ping.cpp, eagine/message_bus/007_pong.cpp, and eagine/message_bus/008_pong_registry.cpp.

◆ find_element()

template<typename T , typename P , typename S , typename E >
static constexpr auto eagine::memory::find_element ( basic_span< T, P, S >  spn,
what 
) -> optionally_valid<S>
staticconstexprnoexcept

Finds the position of the first occurrence of what in a span.

See also
find
find_position
find_element_if
reverse_find_position

Referenced by eagine::memory::slice_inside_brackets().

◆ find_element_if()

template<typename T , typename P , typename S , typename F >
static constexpr auto eagine::memory::find_element_if ( basic_span< T, P, S >  spn,
predicate 
) -> optionally_valid<S>
staticconstexprnoexcept

Finds the position of the first element satisfying predicate in a span.

See also
find
find_position
find_element
reverse_find_position

Referenced by eagine::memory::skip_until(), and eagine::memory::take_until().

◆ find_position()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::find_position ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> optionally_valid<S1>
staticconstexprnoexcept

Finds the position of the first occurrence of what in a span.

See also
find
find_element
find_element_if

Referenced by eagine::memory::find(), eagine::memory::for_each_delimited(), eagine::memory::slice_after(), eagine::memory::slice_before(), and eagine::memory::split_by_first().

◆ generate()

template<typename T , typename P , typename S , typename Generator >
static auto eagine::memory::generate ( basic_span< T, P, S >  spn,
Generator  gen 
) -> basic_span<T, P, S>
inlinestatic

Fills a span with elements generated by a generator callable.

See also
copy
fill
zero
Examples
eagine/make_index.cpp.

Referenced by eagine::application::context_state::random_normal(), eagine::application::context_state::random_uniform(), and eagine::application::context_state::random_uniform_01().

◆ head() [1/2]

template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::head ( basic_span< T, P, S >  s,
l 
) -> basic_span<T, P, S>
staticconstexprnoexcept

◆ head() [2/2]

template<typename Ts , typename Ps , typename Ss , typename Tl , typename Pl , typename Sl >
static constexpr auto eagine::memory::head ( basic_span< Ts, Ps, Ss >  s,
basic_span< Tl, Pl, Sl >  l 
) -> basic_span<Ts, Ps, Ss>
staticconstexprnoexcept

◆ is_sorted() [1/2]

template<typename T , typename P , typename S >
static auto eagine::memory::is_sorted ( basic_span< T, P, S >  spn) -> bool
inlinestatic

Tests if the elements in a span are sorted.

See also
sort
shuffle
make_index

◆ is_sorted() [2/2]

template<typename T , typename P , typename S , typename Compare >
static auto eagine::memory::is_sorted ( basic_span< T, P, S >  spn,
Compare  compare 
) -> bool
inlinestatic

Tests if the elements in a span are sorted according to compare.

See also
sort
shuffle
make_index

Referenced by eagine::memory::is_sorted().

◆ list_to_stream()

template<typename T , typename P , typename S , typename Output >
static auto list_to_stream ( Output &  out,
memory::basic_span< T, P, S >  s 
) -> Output&
related

Helper function for pretty-printing spans as lists into output streams.

See also
write_to_stream

◆ make_index() [1/2]

template<typename T , typename P , typename S , typename I , typename PI , typename SI >
static auto eagine::memory::make_index ( basic_span< T, P, S >  spn,
basic_span< I, PI, SI >  idx 
) -> bool
inlinestatic

Makes the index of a span, into another span.

See also
is_sorted
sort
shuffle

◆ make_index() [2/2]

template<typename T , typename P , typename S , typename I , typename PI , typename SI , typename Compare >
static auto eagine::memory::make_index ( basic_span< T, P, S >  spn,
basic_span< I, PI, SI >  idx,
Compare  compare 
) -> bool
inlinestatic

Makes the index of a span according to compare, into another span.

See also
is_sorted
sort
shuffle
Examples
eagine/make_index.cpp.

◆ make_span_getter() [1/2]

template<typename T , typename P , typename S >
static auto make_span_getter ( span_size_t i,
memory::basic_span< T, P, S >  spn 
)
related

Makes a callable that returns consecutive span elements starting at i.

See also
make_span_putter

The constructed callable object does not take any arguments in the call operator and returns optional values of T.

◆ make_span_getter() [2/2]

template<typename T , typename P , typename S , typename Transform >
static auto make_span_getter ( span_size_t i,
memory::basic_span< T, P, S >  spn,
Transform  transform 
)
related

Makes a callable getting consecutive, transformed span elements starting at i.

See also
make_span_putter

The constructed callable object does not take any arguments in the call operator and returns the result of the transform function. The transform function takes a single optional value of T.

◆ make_span_putter() [1/2]

template<typename T , typename P , typename S >
static auto make_span_putter ( span_size_t i,
memory::basic_span< T, P, S >  spn 
)
related

Makes a callable setting consecutive elements of a span starting at i.

See also
make_span_getter

The constructed callable takes a single value explicitly convertible to T.

◆ make_span_putter() [2/2]

template<typename T , typename P , typename S , typename Transform >
static auto make_span_putter ( span_size_t i,
memory::basic_span< T, P, S >  spn,
Transform  transform 
)
related

Makes a callable setting consecutive elements of a span starting at i.

Parameters
transformtransformation operation to be applied
See also
make_span_getter

The constructed callable takes a single value explicitly convertible to the argument of the transform function.

◆ operator<<()

template<typename T , typename P , typename S >
static auto operator<< ( std::ostream &  out,
memory::basic_span< T, P, S >  s 
) -> std:: enable_if_t<!std::is_same_v<std::remove_const_t<T>, char>, std::ostream&>
related

Operator for printing generic element spans into output streams.

See also
list_to_stream

◆ read_from_stream()

template<typename Input , typename T , typename P , typename S >
static auto read_from_stream ( Input &  in,
memory::basic_span< T, P, S >  s 
) -> auto&
related

Helper function for raw-reading spans from output streams.

See also
write_to_stream

◆ relative()

template<typename T , typename P , typename S >
static constexpr auto eagine::memory::relative ( basic_span< T, P, S >  spn) -> basic_span<T, basic_offset_ptr<T, std::make_signed_t<S>>, S>
staticconstexprnoexcept

Converts argument to span using an offset pointer type.

See also
absolute

Referenced by eagine::memory::relative().

◆ reverse()

template<typename T , typename P , typename S >
static auto eagine::memory::reverse ( basic_span< T, P, S >  spn) -> basic_span<T, P, S>
inlinestatic

Reverses the elements in a span.

See also
transform
shuffle
sort
Examples
eagine/message_bus/001_loopback.cpp, and eagine/message_bus/002_direct.cpp.

◆ reverse_find_position()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::reverse_find_position ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> optionally_valid<S1>
staticconstexprnoexcept

Finds the position of the last occurrence of what in a span.

See also
find_position
find_position_if

Referenced by eagine::memory::slice_after_last(), eagine::memory::slice_before_last(), and eagine::memory::split_by_last().

◆ shrink()

template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::shrink ( basic_span< T, P, S >  s,
l 
) -> basic_span<T, P, S>
staticconstexprnoexcept

Shrinks a span by removing a specified count of elements from both sides.

See also
head
tail
slice
skip
shrink

Referenced by eagine::memory::slice_inside_brackets().

◆ shuffle()

template<typename T , typename P , typename S , typename RandGen >
static auto eagine::memory::shuffle ( basic_span< T, P, S >  spn,
RandGen  rg 
) -> basic_span<T, P, S>
inlinestatic

Shuffles the elements of a span.

See also
reverse
sort
is_sorted

◆ skip()

◆ skip_until()

template<typename T , typename P , typename S , typename Predicate >
static constexpr auto eagine::memory::skip_until ( basic_span< T, P, S >  spn,
Predicate  predicate 
) -> basic_span<T, P, S>
staticconstexprnoexcept

Skips the elements from the front of a span until predicate is satisfied.

See also
take_until

◆ slice()

template<typename T , typename P , typename S , typename I , typename L >
static constexpr auto eagine::memory::slice ( basic_span< T, P, S >  s,
i,
l 
) -> basic_span<T, P, S>
staticconstexprnoexcept

Returns a slice of span starting at specified index with specified length.

See also
head
tail
skip
snip

Referenced by eagine::memory::for_each_chunk(), eagine::memory::head(), and eagine::memory::skip().

◆ slice_after()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_after ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> basic_span<T1, P1, S1>
inlinestatic

Returns a slice of span after the first occurrence of what.

See also
slice_before
find_position

◆ slice_after_last()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_after_last ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> basic_span<T1, P1, S1>
inlinestatic

Returns a slice of span after the last occurrence of what.

See also
reverse_find_position

◆ slice_before()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_before ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> basic_span<T1, P1, S1>
inlinestatic

Returns a slice of span before the first occurrence of what.

See also
slice_after
find_position

◆ slice_before_last()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::slice_before_last ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> basic_span<T1, P1, S1>
inlinestatic

Returns a slice of span before the last occurrence of what.

See also
reverse_find_position

◆ slice_inside_brackets()

template<typename T , typename P , typename S , typename B >
static auto eagine::memory::slice_inside_brackets ( basic_span< T, P, S >  spn,
left,
right 
) -> basic_span<T, P, S>
inlinestaticnoexcept

Returns a slice of span within a pair of brackets.

See also
find_element

◆ snip()

template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::snip ( basic_span< T, P, S >  s,
l 
) -> basic_span<T, P, S>
staticconstexprnoexcept

Snips a specified count of elements from the back of a span.

See also
head
tail
slice
skip
shrink

Referenced by eagine::memory::shrink(), and eagine::memory::strip_suffix().

◆ sort() [1/2]

template<typename T , typename P , typename S >
static auto eagine::memory::sort ( basic_span< T, P, S >  spn) -> basic_span<T, P, S>
inlinestatic

Sorts the elements of a span.

See also
reverse
shuffle
is_sorted
make_index

◆ sort() [2/2]

template<typename T , typename P , typename S , typename Compare >
static auto eagine::memory::sort ( basic_span< T, P, S >  spn,
Compare  compare 
) -> basic_span<T, P, S>
inlinestatic

Sorts the elements of a span according to compare.

See also
reverse
shuffle
is_sorted
make_index

Referenced by eagine::memory::make_index(), and eagine::memory::sort().

◆ split_by_first()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::split_by_first ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> std::tuple<basic_span<T1, P1, S1>, basic_span<T1, P1, S1>>
inlinestatic

Splits a span by the first occurrence of what (before and after, what)

See also
find_position

◆ split_by_last()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static auto eagine::memory::split_by_last ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  what 
) -> std::tuple<basic_span<T1, P1, S1>, basic_span<T1, P1, S1>>
inlinestatic

Splits a span by the last occurrence of what (before and after, what)

See also
reverse_find_position

Referenced by eagine::msgbus::parse_ipv4_addr().

◆ starts_with()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::starts_with ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  with 
) -> bool
staticconstexpr

◆ strip_prefix()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::strip_prefix ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  prefix 
) -> basic_span<T1, P1, S1>
staticconstexpr

Strips the specified prefix from a span.

See also
starts_with
strip_suffix

◆ strip_suffix()

template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 >
static constexpr auto eagine::memory::strip_suffix ( basic_span< T1, P1, S1 >  spn,
basic_span< T2, P2, S2 >  suffix 
) -> basic_span<T1, P1, S1>
staticconstexpr

Strips the specified suffix from a span.

See also
ends_with
strip_prefix

◆ tail() [1/2]

template<typename T , typename P , typename S , typename L >
static constexpr auto eagine::memory::tail ( basic_span< T, P, S >  s,
l 
) -> basic_span<T, P, S>
staticconstexprnoexcept

Returns the last l elements from the back of a span.

See also
head
slice
skip
snip
shrink

◆ tail() [2/2]

template<typename Ts , typename Ps , typename Ss , typename Tl , typename Pl , typename Sl >
static constexpr auto eagine::memory::tail ( basic_span< Ts, Ps, Ss >  s,
basic_span< Tl, Pl, Sl >  l 
) -> basic_span<Ts, Ps, Ss>
staticconstexprnoexcept

Returns the tail of s l.size() elements long.

See also
head
slice
skip
snip
shrink

Referenced by eagine::memory::ends_with().

◆ take_until()

template<typename T , typename P , typename S , typename Predicate >
static constexpr auto eagine::memory::take_until ( basic_span< T, P, S >  spn,
Predicate  predicate 
) -> basic_span<T, P, S>
staticconstexprnoexcept

Takes the elements from the front of a span until predicate is satisfied.

See also
skip_until

◆ transform()

template<typename T , typename P , typename S , typename Transform >
static auto eagine::memory::transform ( basic_span< T, P, S >  spn,
Transform  function 
) -> basic_span<T, P, S>
inlinestatic

Transforms the elements of a span with a function.

See also
reverse
shuffle
sort

Referenced by eagine::memory::transform().

◆ write_to_stream()

template<typename Output , typename T , typename P , typename S >
static auto write_to_stream ( Output &  out,
memory::basic_span< T, P, S >  s 
) -> auto&
related

Helper function for raw-reading spans into output streams.

See also
read_from_stream
list_to_stream

◆ zero()

template<typename T , typename P , typename S >
static auto eagine::memory::zero ( basic_span< T, P, S >  spn) -> std::enable_if_t< std::is_integral_v<T> || std::is_floating_point_v<T>, basic_span<T, P, S>>
inlinestatic

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).