mrdocs::dom::LazyArrayImpl

Lazy array implementation

Synopsis

Declared in <mrdocs/Dom/LazyArray.hpp>

template<
    std::ranges::random_access_range R,
    class Context = /* implementation-defined */>
requires HasValueFrom<std::ranges::range_value_t<R>, Context> ||
       (std::invocable<Context, std::ranges::range_value_t<R>> &&
        HasStandaloneValueFrom<std::invoke_result_t<Context, std::ranges::range_value_t<R>>>)
class LazyArrayImpl
    : public ArrayImpl

Base Classes

Name

Description

ArrayImpl

Abstract array interface.

Types

Name

Description

size_type

An unsigned integral type used for indexes and sizes.

value_type

The type of an element.

Member Functions

Name

Description

LazyArrayImpl [constructor]

Constructors

~LazyArrayImpl [destructor] [virtual]

Destructor

emplace_back [virtual]

Append an element to the end of the array.

get [virtual]

Return the i‐th element, without bounds checking.

set [virtual]

Set the i‐th element, without bounds checking.

size [virtual]

type_key [virtual]

Return the type key of the implementation.

Description

This array type is used to define a dom::Array whose members are evaluated on demand as they are accessed.

Each member can goes through a transform function before being returned as a Value so that all types can be converted to dom::Value.

The underlying representation of the array is a range from where the elements are extracted. Elements in this range should be convertible to dom::Value.

This class is typically useful for implementing arrays that are expensive and have recursive dependencies, as these recursive dependencies can also be deferred.

Unlike a LazyObjectImpl, which contains an overlay object, this implementation is read‐only. The set and emplace_back methods are not implemented.

Created with MrDocs