NPRPC docs

class Optional_Direct

C++

template <typename T, typename TD = void> class Optional_Direct

Accessor for an optional (name?: T) field. value() returns T& for plain types and the TD accessor for messages and strings.

include/nprpc/flat.hpp:557

Constructors

Optional_Direct<T, TD>(flat_buffer &buffer, std::uint32_t offset)

The field at offset in buffer; created by generated code.

include/nprpc/flat.hpp:603

Methods

void alloc() noexcept

Makes room for a value, which value() then fills in.

include/nprpc/flat.hpp:582

bool has_value() const noexcept

Whether the field holds a value.

include/nprpc/flat.hpp:586

void set_nullopt() noexcept

Marks the field as empty.

include/nprpc/flat.hpp:584

value_ret_t value() noexcept

The value; only when has_value().

include/nprpc/flat.hpp:592

Type aliases

using value_ret_t = std::conditional_t<std::is_same_v<TD, void>, T &, TD>

What value() returns.

include/nprpc/flat.hpp:589