Lazy object implementation.

Synopsis

Declared in <mrdocs/Dom/LazyObject.hpp>

template<
    class T,
    class Context = /* implementation-defined */>
requires HasLazyObjectMap<T, Context>
class LazyObjectImpl
    : public ObjectImpl

Base Classes

Name

Description

ObjectImpl

Abstract object interface.

Types

Name

Description

reference

A reference to an element.

storage_type

The type of storage used by the default implementation.

Member Functions

Name

Description

LazyObjectImpl [constructor]

Constructors

~LazyObjectImpl [destructor] [virtual]

Destructor

exists [virtual]

Determine if a key exists.

get [virtual]

Return the value for the specified key, or null.

set [virtual]

Insert or set the given key/value pair.

size [virtual]

Return the number of properties in the object.

type_key [virtual]

Return the type key of the implementation.

visit [virtual]

Invoke the visitor for each key/value pair.

Description

This interface is used to define objects whose members are evaluated on demand as they are accessed.

When any of the object properties are accessed, the object dom::Value is constructed. In practice, the object never takes any memory besides the pointer to the underlying object.

The keys and values in the underlying object should be mapped using tag_invoke.

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

A context can also be stored in the object as a form to customize how the object is mapped. This context should be copyable and is propagated to other objects that support an overload with the same context.

The context can be simply a tag identifying how to map the object, or a more complex object carrying data to customize the mapping process.

In the latter case, because the context should be a copyable, the user might want to use a type with reference semantics.

Created with MrDocs