Essentials

cvar

A dynamic value for scalars, collections, symbols, expressions, and native objects.

C++23 mc/cvar.h
#include <mc/cvar.h>

cvar remains 16 bytes. cnone denotes absence; cnull is an explicit null value. The assigned type codes and tag fields are listed below.

Ordinary scalar and collection copies have value semantics. Explicit references, pointers, and native objects have separate lifetime rules. Borrowed references and indexing proxies do not keep their parent value alive.

csym names a symbol; cfunc holds a name and argument vector. An expression is data until an executor evaluates it. Callable Func0–Func15 values wrap native functions.

Link Catalyst::Shared or Catalyst::Static for formatting, packing, file/archive operations, recursive merging, and memory accounting.

String-key indexing returns a proxy. Its additional forwarded methods are listed on the related cvar_proxy.h page.

Jump to a declaration · 415

ctag

class ctag

Types, constants & data

using Type = uint8_t;
using Kind = uint16_t;
using Attrs = uint32_t;
using Flags = uint8_t;
Type type = 1;
Flags flags = 0;
Kind kind = 0;
Attrs attrs = 0;

Methods

ctag

constexpr ctag();
constexpr ctag(Type type);
constexpr ctag(Kind kind, Attrs attrs, Flags flags = 0);
constexpr ctag(const ctag&) = default;
constexpr ctag(ctag&&) = default;

Creates a default None tag, a tag with an explicit type, or metadata containing kind, attributes, and optional flags. The metadata overload leaves the type at its default; assigning that tag to a cvar updates metadata without changing its stored value type.

operator Type

constexpr operator Type() const;

Returns only the type code; kind, flags, and attributes are not included. Use tag() for the complete packed tag value.

tag

uint64_t tag() const;

Returns the packed tag value including its metadata fields. Conversion to Type reads only the type code.

cvar

class cvar

Types, constants & data

static constexpr uint8_t None = 1;
static constexpr uint8_t Null = 2;
static constexpr uint8_t Bool = 4;
static constexpr uint8_t Integer = 5;
static constexpr uint8_t Float = 6;
static constexpr uint8_t String = 7;
static constexpr uint8_t Symbol = 8;
static constexpr uint8_t Vector = 9;
static constexpr uint8_t Function = 10;
static constexpr uint8_t Map = 11;
static constexpr uint8_t Buffer = 12;
static constexpr uint8_t Packed = 13;
static constexpr uint8_t Reference = 14;
static constexpr uint8_t Pointer = 15;
static constexpr uint8_t Set = 16;
static constexpr uint8_t Object = 17;
static constexpr uint16_t Lambda0 = 260;
static constexpr uint16_t Lambda1 = 261;
static constexpr uint16_t Lambda2 = 262;
static constexpr uint16_t Lambda3 = 263;
static constexpr uint16_t Lambda4 = 264;
static constexpr uint16_t Lambda5 = 265;
static constexpr uint16_t Lambda6 = 266;
static constexpr uint16_t Lambda7 = 267;
static constexpr uint16_t Lambda8 = 268;
static constexpr uint16_t Lambda9 = 269;
static constexpr uint16_t Lambda10 = 270;
static constexpr uint16_t Lambda11 = 271;
static constexpr uint16_t Lambda12 = 272;
static constexpr uint16_t Lambda13 = 273;
static constexpr uint16_t Lambda14 = 274;
static constexpr uint16_t Lambda15 = 275;
using Func0 = std::function<cvar()>;
using Func1 = std::function<cvar(const cvar&)>;
using Func2 = std::function<cvar(const cvar&, const cvar&)>;
using Func3 = std::function<cvar(const cvar&, const cvar&, const cvar&)>;
using Func4 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func5 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func6 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func7 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func8 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func9 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func10 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func11 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func12 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func13 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func14 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
using Func15 = std::function<cvar( const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&, const cvar&)>;
enum : uint8_t { False = 3, True = 4, Tag = 19, SmallInt0 = 20, SmallInt1, SmallInt2, SmallInt3, SmallInt4, SmallInt5, SmallInt6, SmallInt7, SmallInt8, SmallInt9, SmallInt10, SmallInt11, SmallInt12, SmallInt13, SmallInt14, SmallInt15, SmallInt16, SmallInt17, SmallInt18, SmallInt19, SmallInt20, SmallInt21, SmallInt22, SmallInt23, SmallInt24, SmallInt25, SmallInt26, SmallInt27, SmallInt28, SmallInt29, SmallInt30, SmallInt31, SmallInt32, SmallInt33, SmallInt34, SmallInt35, SmallInt36, SmallInt37, SmallInt38, SmallInt39, SmallInt40, SmallInt41, SmallInt42, SmallInt43, SmallInt44, SmallInt45, SmallInt46, SmallInt47, SmallInt48, SmallInt49, SmallInt50, SmallInt51, SmallInt52, SmallInt53, SmallInt54, SmallInt55, SmallInt56, SmallInt57, SmallInt58, SmallInt59, SmallInt60, SmallInt61, SmallInt62, SmallInt63, SmallInt64, SmallInt65, SmallInt66, SmallInt67, SmallInt68, SmallInt69, SmallInt70, SmallInt71, SmallInt72, SmallInt73, SmallInt74, SmallInt75, SmallInt76, SmallInt77, SmallInt78, SmallInt79, SmallInt80, SmallInt81, SmallInt82, SmallInt83, SmallInt84, SmallInt85, SmallInt86, SmallInt87, SmallInt88, SmallInt89, SmallInt90, SmallInt91, SmallInt92, SmallInt93, SmallInt94, SmallInt95, SmallInt96, SmallInt97, SmallInt98, SmallInt99, SmallInt100, SmallInt101, SmallInt102, SmallInt103, SmallInt104, SmallInt105, SmallInt106, SmallInt107, SmallInt108, SmallInt109, SmallInt110, SmallInt111, SmallInt112, SmallInt113, SmallInt114, SmallInt115, SmallInt116, SmallInt117, SmallInt118, SmallInt119, SmallInt120, SmallInt121, SmallInt122, SmallInt123, SmallInt124, SmallInt125, SmallInt126, SmallInt127, Int8, Int16, Int32, Float32, SmallString0, SmallString1, SmallString2, SmallString3, SmallString4, SmallString5, SmallString6, SmallString7, SmallString8, SmallString9, SmallString10, SmallString11, SmallString12, SmallString13, SmallString14, SmallString15, SmallString, SmallVector0, SmallVector1, SmallVector2, SmallVector3, SmallVector4, SmallVector5, SmallVector6, SmallVector7, SmallVector8, SmallVector9, SmallVector10, SmallVector11, SmallVector12, SmallVector13, SmallVector14, SmallVector15, SmallVector, SmallMap0, SmallMap1, SmallMap2, SmallMap3, SmallMap4, SmallMap5, SmallMap6, SmallMap7, SmallMap8, SmallMap9, SmallMap10, SmallMap11, SmallMap12, SmallMap13, SmallMap14, SmallMap15, SmallMap, SmallSymbol0, SmallSymbol1, SmallSymbol2, SmallSymbol3, SmallSymbol4, SmallSymbol5, SmallSymbol6, SmallSymbol7, SmallSymbol8, SmallSymbol9, SmallSymbol10, SmallSymbol11, SmallSymbol12, SmallSymbol13, SmallSymbol14, SmallSymbol15, SmallSymbol, SmallFunction0, SmallFunction1, SmallFunction2, SmallFunction3, SmallFunction4, SmallFunction5, SmallFunction6, SmallFunction7, SmallFunction8, SmallFunction9, SmallFunction10, SmallFunction11, SmallFunction12, SmallFunction13, SmallFunction14, SmallFunction15, SmallFunction, InlineBuffer, InlinePacked, SmallSet };
using cvec = CVector<cvar>;
using cmap = CHashMap<cstr, cvar>;
using cset = CHashSet<cvar, cset_hash>;
static constexpr uint32_t VId = 0x73f3719f;
static constexpr uint8_t InlineBuffers = 0b1;

Methods

cvar

cvar() noexcept;
cvar(ctag t) noexcept;
cvar(bool x) noexcept;
template<CInteger T> cvar(T x) noexcept;
template<CFloat T> cvar(T x) noexcept;
template<class T> cvar(const std::atomic<T>& a);
template<CString T> cvar(T&& x);
cvar(const cvec& x);
cvar(cvec&& x);
cvar(const cset& x);
cvar(cset&& x);
cvar(const cmap& x);
cvar(cmap&& x);
cvar(void* p) noexcept;
cvar(CObject* o) noexcept;
cvar(cvar* v) noexcept;
cvar(const cvar& v);
cvar(cvar&& v) noexcept;
cvar(std::initializer_list<cvar> il);
template<class T, int N> cvar(const CPVector<T, N>& v);
cvar(CBuffer* b) noexcept;
cvar(const csym& s);
cvar(csym&& s);
cvar(const cfunc& f);
cvar(cfunc&& f);
explicit cvar(CBuffer& b);
template<CItems T> cvar(const T& x);
template<class T, size_t N> cvar(const CArray<T, N>& x);
template<CAnyMap T> cvar(const T& x);
template<CString K> cvar(const cvar_proxy<K>& v);

Constructs a dynamic value, Null by default; initializer lists form vectors. CBuffer& decodes a serialized value, whereas CBuffer* transfers ownership of a nonpersistent buffer. A cvar* creates a borrowed reference, void* a borrowed native pointer, and CObject* a reference-counted object value.

operator=

cvar& operator=(const ctag& t) noexcept;
cvar& operator=(const cvar& v);
cvar& operator=(cvar&& v) noexcept;
cvar& operator=(std::initializer_list<cvar> il);
template<class T, int N> cvar& operator=(const CPVector<T, N>& v);
template<class T, size_t N> cvar& operator=(const CArray<T, N>& v);
cvar& operator=(bool x) noexcept;
template<CInteger T> cvar& operator=(T x) noexcept;
template<CFloat T> cvar& operator=(T x) noexcept;
template<CString T> cvar& operator=(T&& x);
template<class T> requires(CSame<T, cvec>) cvar& operator=(T&& x);
template<class T> requires(CSame<T, cset>) cvar& operator=(T&& x);
template<class T> requires(CSame<T, cmap>) cvar& operator=(T&& x);
cvar& operator=(CBuffer* b) noexcept;
template<class T> requires(CSame<T, csym>) cvar& operator=(T&& x);
template<class T> requires(CSame<T, cfunc>) cvar& operator=(T&& x);
cvar& operator=(void* x) noexcept;
cvar& operator=(CObject* x) noexcept;
cvar& operator=(cvar* x) noexcept;
template<class T> cvar& operator=(const std::atomic<T>& a) noexcept(noexcept(*this = a.load()));
template<CString K> cvar& operator=(const cvar_proxy<K>& x);

Replaces this value, releasing its previous owned contents. Pointer overloads retain the constructor ownership distinctions; assigning a value to a reference-valued cvar is different from explicitly writing through its referent.

to

template<class T> void to(CVector<T>& x) const;
template<class T> void to(CList<T>& x) const;
template<class T> void to(CDeque<T>& x) const;
template<class T> void to(CSet<T>& x) const;
template<class T> void to(CHashSet<T>& x) const;
template<class K, class V, class H> void to(CHashMap<K, V, H>& x) const;
template<class K, class V> void to(CMap<K, V>& x) const;
template<class K, class V> void to(CMultimap<K, V>& x) const;

Inserts converted elements into the destination container; existing destination contents are retained.

tag

ctag& tag() noexcept;
ctag tag() const noexcept;

Returns the effective tag, following explicit references.

rawTag

ctag& rawTag() noexcept;
ctag rawTag() const noexcept;

Returns the stored tag directly.

type

uint8_t type() const noexcept;

Returns the effective type, following explicit references.

rawType

uint8_t rawType() const noexcept;

Returns the stored tag’s type code without following a reference.

kind

uint16_t kind() const noexcept;

Returns the application-defined kind code from the effective tag, following a reference.

rawKind

uint16_t rawKind() const noexcept;

Returns the kind code on this value’s own tag without following a reference.

head

cvar& head();
const cvar& head() const;

Returns the # entry of a map, follows a reference, or returns this value for other types.

storeVec

template<uint8_t Flags = 0> static void storeVec(CBuffer& b, const cvec& v);

Writes a vector in the tagged cvar serialization format, including its length and recursively stored elements. Serialization flags are forwarded to each element.

storeSet

template<uint8_t Flags = 0> static void storeSet(CBuffer& b, const cset& v);

Writes a set in the tagged cvar serialization format. Element order follows set iteration; serialization flags are forwarded to each value.

storeMap

template<uint8_t Flags = 0> static void storeMap(CBuffer& b, const cmap& m);

Writes a map in the tagged cvar serialization format, including key strings and recursively stored values. Serialization flags are forwarded to the values.

store

template<uint8_t Flags = 0> void store(CBuffer& b) const;

Appends the value in Catalyst’s binary representation. Set the InlineBuffers template flag to inline attached buffers.

restore

template<class T> T restore();

Extracts a native T from a Buffer value using CBuffer::get<T>(), then consumes the buffer and leaves this value Null.

as

template<class T> requires(std::same_as<T, bool>) bool as() const;
template<CNumeric T> T as() const;
template<class T> requires(std::same_as<T, int64_t&>) int64_t& as();
template<class T> requires(std::same_as<T, double&>) double& as();
template<class T> requires(CSame<T, cstr>) cstr& as();
template<class T> requires(CSame<T, cstr>) const cstr& as() const;
template<class T> requires(CSame<T, cvec>) cvec& as();
template<class T> requires(CSame<T, cvec>) const cvec& as() const;
template<class T> requires(CSame<T, cset>) cset& as();
template<class T> requires(CSame<T, cset>) const cset& as() const;
template<class T, int N> requires(std::same_as<T, CPVector<T, N>>) CPVector<T, N> as() const;
template<class T> requires(CSame<T, cmap>) cmap& as();
template<class T> requires(CSame<T, cmap>) const cmap& as() const;
template<class T> requires(CSame<T, csym>) csym& as();
template<class T> requires(CSame<T, csym>) const csym& as() const;
template<class T> requires(CSame<T, cfunc>) cfunc& as();
template<class T> requires(CSame<T, cfunc>) const cfunc& as() const;
template<class T> requires(std::is_pointer_v<T> && !std::is_convertible_v<T, const CObject*>) T as() const;
template<class T> requires(std::is_pointer_v<T> && std::is_convertible_v<T, const CObject*>) T as() const;
template<class T> requires(CSame<T, CBuffer>) CBuffer& as();
template<class T> requires(CSame<T, CBuffer>) const CBuffer& as() const;

Checked typed access or scalar conversion. Unsupported conversions raise CError; returned references remain borrowed.

get

template<class T> requires(CSame<T, cvar>) cvar& get() noexcept;
template<class T> requires(CSame<T, cvar>) const cvar& get() const noexcept;
template<class T> requires(CSame<T, bool>) bool get() const noexcept;
template<class T> requires(CSame<T, int64_t>) int64_t& get() noexcept;
template<class T> requires(CSame<T, double>) double& get() noexcept;
template<CInteger T> T get() const noexcept;
template<CFloat T> T get() const noexcept;
template<class T> requires(CSame<T, cstr>) cstr& get() noexcept;
template<class T> requires(CSame<T, cstr>) const cstr& get() const noexcept;
template<class T> requires(CSame<T, cvec>) cvec& get() noexcept;
template<class T> requires(CSame<T, cvec>) const cvec& get() const noexcept;
template<class T, int N> requires(std::same_as<T, CPVector<T, N>>) CPVector<T, N> get() const;
template<class T> requires(CSame<T, cset>) cset& get() noexcept;
template<class T> requires(CSame<T, cset>) const cset& get() const noexcept;
template<class T> requires(CSame<T, cmap>) cmap& get() noexcept;
template<class T> requires(CSame<T, cmap>) const cmap& get() const noexcept;
template<class T> requires(CSame<T, csym>) csym& get() noexcept;
template<class T> requires(CSame<T, csym>) const csym& get() const noexcept;
template<class T> requires(CSame<T, cfunc>) cfunc& get() noexcept;
template<class T> requires(CSame<T, cfunc>) const cfunc& get() const noexcept;
template<class T> requires(std::is_pointer_v<T> && !std::is_convertible_v<T, const CObject*>) T get() noexcept;
template<class T> requires(std::is_pointer_v<T> && std::is_convertible_v<T, const CObject*>) T get() noexcept;
template<class T> requires(CSame<T, CBuffer>) CBuffer& get() noexcept;
template<class T> requires(CSame<T, CBuffer>) const CBuffer& get() const noexcept;
template<CString K> cvar get(K&& k, const cvar& def) const;
cvar get(const cvar& k, const cvar& def) const;

Typed zero-argument overloads require the matching stored type. Key-and-default overloads return a value or the fallback without inserting the key.

is

template<class T> requires(std::same_as<T, void>) bool is() const noexcept;
template<class T> requires(std::same_as<T, bool>) bool is() const noexcept;
template<CInteger T> bool is() const noexcept;
template<CFloat T> bool is() const noexcept;
template<class T> requires(CSame<T, cstr>) bool is() const noexcept;
template<class T> requires(CSame<T, cvec>) bool is() const noexcept;
template<class T> requires(CSame<T, cset>) bool is() const noexcept;
template<class T> requires(CSame<T, cmap>) bool is() const noexcept;
template<class T> requires(CSame<T, csym>) bool is() const noexcept;
template<class T> requires(CSame<T, cfunc>) bool is() const noexcept;
template<class T> requires(CSame<T, CBuffer>) bool is() const noexcept;
template<class T> requires(std::is_pointer_v<T> && !std::is_convertible_v<T, const CObject*>) bool is() const noexcept;
template<class T> requires(std::is_pointer_v<T> && std::is_convertible_v<T, const CObject*>) bool is() const noexcept;

Checks the effective stored category for T, following references. It does not test whether as<T>() could perform a conversion; is<CBuffer>() accepts both Buffer and Packed.

operator*

cvar& operator*() const noexcept;
template<class T> cvar operator*(T&& x) const;
template<CNumeric T> friend cvar operator*(T x, const cvar& v);

Performs dynamic mul arithmetic on numeric values or component-wise on compatible vectors. Unsupported operands raise CError; vector sizes must be compatible. The zero-argument unary overload instead returns a borrowed referent, or this value for a non-reference.

deref

cvar& deref() const noexcept;

Returns the referent for an ordinary reference, but preserves a reference carrying the no-dereference flag. This supports interpreter value/lvalue handling; it does not copy the value.

Star

cvar Star();

Follows references and dispatches the runtime Star operation for an object. Ordinary non-object values are returned as value copies.

operator->

cvar* operator->() const noexcept;

Returns the referenced cvar, or this value for a non-reference. The returned pointer is borrowed and does not extend the referent’s lifetime.

dump

__attribute__((used)) cstr dump() const;

Returns the same display text as toStr(). Use a CSON/JSON generator or binary storage for an explicit document format.

toStr

cstr toStr() const;

Formats the value as display text; string values return their contents without adding quotes. Objects may provide a Str method, otherwise their address is formatted.

operator<<

template<class T> cvar& operator<<(T&& x);
friend std::ostream& operator<<(std::ostream& ostr, const cvar& v);

Appends to a vector or function argument list, or inserts into a set. A Null value becomes a vector on first insertion; objects receive Push. Returns this value for chaining.

pushFront

template<class T> void pushFront(T&& x);

Prepends to a vector or function argument list. A Null value becomes a vector; objects receive pushFront.

operator[]

cvar& operator[](size_t i);
const cvar& operator[](size_t i) const;
template<CString K> cvar_proxy<K> operator[](K&& k);
template<CString K> const cvar_proxy<K> operator[](K&& k) const;

Numeric indices borrow vector elements or function arguments and must be in range. String keys return a map proxy: writes can insert keys, while const access requires a map. Proxies borrow their parent and may borrow the key.

operator()

cvar operator()() const;
cvar operator()(const cvar& v1) const;
cvar operator()(const cvar& v1, const cvar& v2) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8, const cvar& v9) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8, const cvar& v9, const cvar& v10) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8, const cvar& v9, const cvar& v10, const cvar& v11) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8, const cvar& v9, const cvar& v10, const cvar& v11, const cvar& v12) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8, const cvar& v9, const cvar& v10, const cvar& v11, const cvar& v12, const cvar& v13) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8, const cvar& v9, const cvar& v10, const cvar& v11, const cvar& v12, const cvar& v13, const cvar& v14) const;
cvar operator()(const cvar& v1, const cvar& v2, const cvar& v3, const cvar& v4, const cvar& v5, const cvar& v6, const cvar& v7, const cvar& v8, const cvar& v9, const cvar& v10, const cvar& v11, const cvar& v12, const cvar& v13, const cvar& v14, const cvar& v15) const;

Invokes a stored native Func0–Func15 callable with the matching argument count. A cfunc expression is data and must instead be evaluated by an interpreter or executor.

back

cvar& back();
const cvar& back() const;

Returns the last vector element or function argument by reference; the sequence must be nonempty. Objects may implement the corresponding runtime operation.

front

cvar& front();
const cvar& front() const;

Returns the first vector element or function argument by reference; the sequence must be nonempty. Objects may implement the corresponding runtime operation.

operator T

template<CArithmetic T> operator T() const;

Converts to an arithmetic type using as<T>(), following references and supported conversions. Unsupported categories throw CError; narrowing does not add a separate range check.

operator cstr&

operator cstr&();

Provides checked borrowed access through as<cstr>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cstr&

operator const cstr&() const;

Provides checked borrowed access through as<cstr>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cvec&

operator cvec&();

Provides checked borrowed access through as<cvec>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cvec&

operator const cvec&() const;

Provides checked borrowed access through as<cvec>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cset&

operator cset&();

Provides checked borrowed access through as<cset>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cset&

operator const cset&() const;

Provides checked borrowed access through as<cset>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cmap&

operator cmap&();

Provides checked borrowed access through as<cmap>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cmap&

operator const cmap&() const;

Provides checked borrowed access through as<cmap>(). It does not create a copy; the owning value and any followed references must remain valid.

operator csym&

operator csym&();

Provides checked borrowed access through as<csym>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const csym&

operator const csym&() const;

Provides checked borrowed access through as<csym>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cfunc&

operator cfunc&();

Provides checked borrowed access through as<cfunc>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cfunc&

operator const cfunc&() const;

Provides checked borrowed access through as<cfunc>(). It does not create a copy; the owning value and any followed references must remain valid.

operator CBuffer&

operator CBuffer&();

Provides checked borrowed access through as<CBuffer>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const CBuffer&

operator const CBuffer&();

Provides checked borrowed access through as<CBuffer>(). It does not create a copy; the owning value and any followed references must remain valid.

b1

bool b1() const;

Converts through as<bool>(). Boolean conversion follows Catalyst’s accepted categories, not general string or collection truthiness.

i8

int64_t i8() const;

Converts through as<int64_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

i4

int32_t i4() const;

Converts through as<int32_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

i2

int16_t i2() const;

Converts through as<int16_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

i1

int8_t i1() const;

Converts through as<int8_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

s8

size_t s8() const;

Converts through as<size_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

u8

uint64_t u8() const;

Converts through as<uint64_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

u4

uint32_t u4() const;

Converts through as<uint32_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

u2

uint16_t u2() const;

Converts through as<uint16_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

u1

uint8_t u1() const;

Converts through as<uint8_t>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

f4

float f4() const;

Converts through as<float>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

f8

double f8() const;

Converts through as<double>(). Unsupported value categories raise CError; numeric narrowing follows C++ conversion rules without an additional range check.

str

cstr& str();
const cstr& str() const;

Checked access through as<cstr>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

vec

cvec& vec();
const cvec& vec() const;

Checked access through as<cvec>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

set

cset& set();
const cset& set() const;

Checked access through as<cset>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

map

cmap& map();
const cmap& map() const;

Checked access through as<cmap>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

sym

csym& sym();
const csym& sym() const;

Checked access through as<csym>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

buf

CBuffer& buf();
const CBuffer& buf() const;

Checked access through as<CBuffer>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

func

cfunc& func();
const cfunc& func() const;

Checked access through as<cfunc>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

obj

CObject* obj() const;

Checked access through as<CObject*>(), following references and applicable map # heads. The result is borrowed; it does not create an independent copy or owning handle.

getBool

bool getBool() const noexcept;

Direct access to the raw Bool payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getInt

int64_t& getInt() noexcept;
int64_t getInt() const noexcept;

Direct access to the raw Integer payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getFloat

double& getFloat() noexcept;
double getFloat() const noexcept;

Direct access to the raw Float payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getStr

cstr& getStr() noexcept;
const cstr& getStr() const noexcept;

Direct access to the raw String payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getVec

cvec& getVec() noexcept;
const cvec& getVec() const noexcept;

Direct access to the raw Vector payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getSet

cset& getSet() noexcept;
const cset& getSet() const noexcept;

Direct access to the raw Set payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getMap

cmap& getMap() noexcept;
const cmap& getMap() const noexcept;

Direct access to the raw Map payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getSym

csym& getSym() noexcept;
const csym& getSym() const noexcept;

Direct access to the raw Symbol payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getFunc

cfunc& getFunc() noexcept;
const cfunc& getFunc() const noexcept;

Direct access to the raw Function payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getBuf

CBuffer& getBuf() noexcept;
const CBuffer& getBuf() const noexcept;

Direct access to the raw Buffer or Packed payload. Establish the matching raw type first; this does not follow references or perform conversion, and returned references are borrowed.

getRef

cvar& getRef() const noexcept;

Returns the borrowed referent of a value whose raw type is Reference. The caller must establish that type before calling; this accessor does not perform a checked conversion.

getPtr

template<class T = void*> T getPtr() const;

Returns the stored native pointer cast to T. Requires the raw Pointer type and does not check the pointee’s dynamic type or transfer ownership.

getObj

template<class T = CObject*> T getObj() const;

Returns the stored object pointer cast to T. Requires the raw Object type; this static cast does not verify the dynamic class or add an owning reference.

isNull

bool isNull() const noexcept;

Tests whether the effective type is Null, following one stored reference. It does not perform a conversion or inspect a map’s head.

isNone

bool isNone() const noexcept;

Tests whether the effective type is None, following one stored reference. It does not perform a conversion or inspect a map’s head.

isBool

bool isBool() const noexcept;

Tests whether the effective type is Bool, following one stored reference. It does not perform a conversion or inspect a map’s head.

isInt

bool isInt() const noexcept;

Tests whether the effective type is Integer, following one stored reference. It does not perform a conversion or inspect a map’s head.

isFloat

bool isFloat() const noexcept;

Tests whether the effective type is Float, following one stored reference. It does not perform a conversion or inspect a map’s head.

isStr

bool isStr() const noexcept;

Tests whether the effective type is String, following one stored reference. It does not perform a conversion or inspect a map’s head.

isVec

bool isVec() const noexcept;

Tests whether the effective type is Vector, following one stored reference. It does not perform a conversion or inspect a map’s head.

isSet

bool isSet() const noexcept;

Tests whether the effective type is Set, following one stored reference. It does not perform a conversion or inspect a map’s head.

isMap

bool isMap() const noexcept;

Tests whether the effective type is Map, following one stored reference. It does not perform a conversion or inspect a map’s head.

isBuf

bool isBuf() const noexcept;

Reports whether the effective type is Buffer or Packed. Use isPacked() to distinguish compressed packed values.

isPtr

bool isPtr() const noexcept;

Tests whether the effective type is Pointer, following one stored reference. It does not perform a conversion or inspect a map’s head.

isObj

bool isObj() const noexcept;

Tests whether the effective type is Object, following one stored reference. It does not perform a conversion or inspect a map’s head.

isSym

bool isSym() const noexcept;
template<CString T> bool isSym(T&& s) const;

Tests for a symbol, optionally matching its name. A named lookup uses the symbol’s cached hash, which must be refreshed after direct name changes.

isRef

bool isRef() const noexcept;

Tests the raw tag for an explicit reference. Other category predicates normally follow the reference first.

isFunc

bool isFunc() const noexcept;
template<CString T> bool isFunc(T&& f) const;
template<CString T> bool isFunc(T&& f, size_t arity) const;
template<CString T> bool isFunc(T&& f, size_t minArity, size_t maxArity) const;

Tests for a function expression, optionally matching its name, exact arity, or inclusive arity range. Native Func0–Func15 callables are a different category.

isSymbolic

bool isSymbolic() const noexcept;

Reports whether the effective value is a symbol or function expression. It does not evaluate that expression.

isNumeric

bool isNumeric() const noexcept;

Reports whether the effective type is Integer or Float. Bool and convertible strings are not classified as numeric.

isPacked

bool isPacked() const noexcept;

Tests whether the effective type is Packed, following one stored reference. It does not perform a conversion or inspect a map’s head.

size

size_t size() const;

Counts vector elements, set elements, or function arguments, and forwards to objects and references. Other types, including strings and maps, return zero; use str().size() or map().size() for those.

empty

bool empty() const;

Checks vectors, sets, and function arguments, forwarding to objects and references. Other types return true even when a contained string or map has contents.

span

cspan span() const;
cspan span(size_t start) const;
cspan span(size_t start, size_t endOffset) const;

Returns numeric indices rather than an element view.

at

cvar& at(const cstr& k);
const cvar& at(const cstr& k) const;

Returns a map entry by reference without insertion. A missing key or incompatible value type raises CError; objects may supply the runtime at operation.

has

template<CString K> bool has(K&& k) const;
template<class K> requires(!CString<K>) bool has(K&& k) const;

Checks membership in a vector or set, or key presence in a map. Non-string keys are formatted for map lookup; unsupported ordinary value types return false.

erase

template<CString K> void erase(K&& k);
void erase(const cvar& k);
template<class K> requires(!CString<K> && !CSame<K, cvar>) void erase(K&& k);
void erase(const cvar& first, const cvar& last);

Key overloads erase map/set entries. Iterator overloads erase sequence elements; use compatible iterators from the same live value.

take

cvar take(const cstr& k) const;
cvar take(const cstr& k, cvar def) const;

Moves a map entry out and removes its key. The fallback overload returns its default when the key is missing.

innerMerge

void innerMerge(const cvar& v);
void innerMerge(const cmap& m);

The cvar overload recursively adds missing map entries while preserving existing leaves; maps containing # are left intact. The cmap overload merges immediate keys only.

outerMerge

void outerMerge(const cvar& v);
void outerMerge(const cmap& m);

The cvar overload recursively merges maps and replaces non-map leaves. Maps containing # are replaced as whole values; a plain target map is retained when the incoming value is not a map. The cmap overload merges immediate keys only.

begin_

cvar begin_();

Returns a runtime iterator represented by a cvar, suitable for interpreted traversal.

end_

cvar end_();

Returns the corresponding runtime end iterator.

find

cvar find(const cvar& key);

Returns a runtime map iterator for a key.

begin

cvec::iterator begin();
cvec::const_iterator begin() const;

Returns a C++ iterator over vector elements or function arguments. Map and set traversal require their typed container accessors or the runtime iterator API.

end

cvec::iterator end();
cvec::const_iterator end() const;

Returns the matching past-the-end iterator for vector elements or function arguments. It must be compared with iterators from the same live value.

hash

chash hash(uint64_t seed = CHashDefaultSeed) const;

Computes the seeded value hash recursively. Map and set hashes do not depend on iteration order; numerically equal integral floats and integers share hashes.

hash64

chash64 hash64(uint64_t seed = CHashDefaultSeed) const;

Computes the 64-bit form of the seeded value hash. This is a hash of value content, not an identity or unique ID.

memoryUsage

size_t memoryUsage() const;

Estimates the value’s recursively owned memory usage.

pack

void pack(int compressLevel = -1);

Replaces the value with its compressed packed representation. A Buffer value is rejected; an already Packed value is unchanged.

unpack

void unpack();

Restores a Packed value. Other ordinary types are rejected.

save

void save(const cstr& path, int compressLevel = -1) const;

Stores the value in a file; use open() to restore it.

open

void open(const cstr& path);

Loads an archive written by save() and replaces this value. Checks the archive marker and decompresses the stored value.

skip

static void skip(CBuffer& b);

Advances over one serialized value in a buffer without materializing it. The cursor must begin at that value’s type code.

skip_

static void skip_(CBuffer& b, uint8_t t);

Skips the payload for a type code already read by the caller. Prefer skip() when the buffer cursor is at the beginning of a serialized value.

execute

cvar execute(const cfunc& f) const;

Sends the supplied function node to the stored object’s CExecutor::execute() implementation. The receiver must resolve to an Object; this is not a general evaluator for a cfunc held in this value.

unite

template<class T> void unite(T&& x);

Adds elements to a stored set using set union, or delegates to an object. Other ordinary value categories are rejected.

intersect

template<class T> void intersect(T&& x);

Retains only elements shared with the supplied set, or delegates to an object. The receiver is modified.

complement

template<class T> void complement(T&& x);

Removes elements present in the supplied set, or delegates to an object. This is the receiver minus the argument.

clear

void clear();

Clears a string, vector, set, map, or function argument list while retaining its category. Objects can implement clear; other ordinary categories are rejected.

popBack

cvar popBack();

Removes and returns the last vector element, function argument, or string byte. A string returns a one-character string value; the sequence must be nonempty.

popFront

cvar popFront();

Removes and returns the first vector element, function argument, or string byte. A string returns a one-character string value; the sequence must be nonempty.

append

void append(const cvar& v);

Appends string text or sequence elements to the receiver, including a function’s argument vector. This appends the source contents; use operator<< to append a single nested value.

insert

template<class T> void insert(size_t i, T&& x);

Inserts text, a vector element, or a function argument before a valid numeric position. Objects may implement the same operation.

strip

void strip();

Trims whitespace from both ends of a stored string in place. References forward the operation, and objects may implement it.

startsWith

template<class T> cvar startsWith(T&& s);

Returns a boolean value indicating a stored string prefix match. References forward the operation, and objects may implement it.

endsWith

template<class T> cvar endsWith(T&& s);

Returns a boolean value indicating a stored string suffix match. References forward the operation, and objects may implement it.

split

cvar split(const cstr& delimiter);

Splits a string on a nonempty delimiter and returns a vector of strings, retaining empty fields. References forward the operation, and objects may implement it.

substr

cvar substr(size_t pos = 0, size_t n = cstr::npos);

Returns a byte substring of a stored string. The original string is unchanged; a start beyond its end raises CError.

findReplace

cvar findReplace(const cstr& value, const cstr& replacement, bool all = true);

Replaces string matches in place and returns their count as a cvar. all = false changes only the first occurrence; the search string must be nonempty.

replace

void replace(size_t pos, size_t n, const cstr& s);

Replaces n string bytes at pos with the supplied text. The replacement can change the string length.

intoAllUpper

void intoAllUpper();

Converts all characters in place; toAllUpper() returns a converted copy. Requires a String value or a reference to one.

intoAllLower

void intoAllLower();

Converts all characters in place; toAllLower() returns a converted copy. Requires a String value or a reference to one.

intoUpper

void intoUpper();

Converts the first character in place; toUpper() returns a converted copy. The string must be nonempty. Requires a String value or a reference to one.

intoLower

void intoLower();

Converts the first character in place; toLower() returns a converted copy. The string must be nonempty. Requires a String value or a reference to one.

toAllUpper

cstr toAllUpper();

Returns a copy with all characters converted to uppercase using the C character-conversion rules. This is not Unicode case conversion. Requires a String value or a reference to one.

toAllLower

cstr toAllLower();

Returns a copy with all characters converted to lowercase using the C character-conversion rules. This is not Unicode case conversion. Requires a String value or a reference to one.

toUpper

cstr toUpper();

Returns a copy with only the first character uppercased; the string must be nonempty. Requires a String value or a reference to one.

toLower

cstr toLower();

Returns a copy with only the first character lowercased; the string must be nonempty. Requires a String value or a reference to one.

resize

void resize(size_t n);

Changes a string’s byte length, vector size, or function argument count. Objects may implement this operation; changing function arity requires a later rehash().

reserve

void reserve(size_t n);

Requests capacity for a string, vector, or function argument list without changing its logical size. Existing references can be invalidated if storage grows.

indexOf

template<class T> size_t indexOf(T&& x) const;

Returns the index of the first equal vector element or function argument, or its size when absent. Objects may implement their own index lookup.

keyForValue

cstr keyForValue(const cvar& v) const;

Scans a map for an equal value and returns the first corresponding key in iteration order. Raises CError when no value matches.

keys

cvec keys();

Returns a new vector of a map’s keys. Objects may implement the runtime keys operation.

wrap

template<class T> static cvar wrap(T&& value, uint16_t kind);

Owns a native value in an object wrapper and assigns the supplied kind code. Copies share the wrapped object; native wrappers are not a portable storage or binding format.

unwrap

template<class T> T& unwrap(const cstr& name) const;

Returns the native value after checking its C++ wrapper type. name supplies the expected-type text in an error message.

construct

template<CString T, class... Args> static CObject* construct(T&& object, Args&&... args);

Constructs a registered runtime object using its class name and arguments.

operator==

template<class T> bool operator==(T&& x) const;
template<CNumeric T> friend bool operator==(T x, const cvar& v);

Performs dynamic equality comparison and returns a C++ boolean. Numeric types compare by numeric value, collections compare by their contents, and unlike ordinary categories use type ordering; object comparisons dispatch to the object.

EQ

template<class T> cvar EQ(T&& x) const;

Performs the corresponding dynamic comparison and returns a cvar. Unlike the C++ boolean operator, comparisons involving None and most ordinary values can propagate None instead of returning false.

operator!=

template<class T> bool operator!=(T&& x) const;
template<CNumeric T> friend bool operator!=(T x, const cvar& v);

Performs dynamic inequality comparison and returns a C++ boolean. Numeric types compare by numeric value, collections compare by their contents, and unlike ordinary categories use type ordering; object comparisons dispatch to the object.

NE

template<class T> cvar NE(T&& x) const;

Performs the corresponding dynamic comparison and returns a cvar. Unlike the C++ boolean operator, comparisons involving None and most ordinary values can propagate None instead of returning false.

operator<

template<class T> bool operator<(T&& x) const;
template<CNumeric T> friend bool operator<(T x, const cvar& v);

Performs dynamic less-than comparison and returns a C++ boolean. Numeric types compare by numeric value, collections compare by their contents, and unlike ordinary categories use type ordering; object comparisons dispatch to the object.

LT

template<class T> cvar LT(T&& x) const;

Performs the corresponding dynamic comparison and returns a cvar. Unlike the C++ boolean operator, comparisons involving None and most ordinary values can propagate None instead of returning false.

operator>

template<class T> bool operator>(T&& x) const;
template<CNumeric T> friend bool operator>(T x, const cvar& v);

Performs dynamic greater-than comparison and returns a C++ boolean. Numeric types compare by numeric value, collections compare by their contents, and unlike ordinary categories use type ordering; object comparisons dispatch to the object.

GT

template<class T> cvar GT(T&& x) const;

Performs the corresponding dynamic comparison and returns a cvar. Unlike the C++ boolean operator, comparisons involving None and most ordinary values can propagate None instead of returning false.

operator<=

template<class T> bool operator<=(T&& x) const;
template<CNumeric T> friend bool operator<=(T x, const cvar& v);

Performs dynamic less-or-equal comparison and returns a C++ boolean. Numeric types compare by numeric value, collections compare by their contents, and unlike ordinary categories use type ordering; object comparisons dispatch to the object.

LE

template<class T> cvar LE(T&& x) const;

Performs the corresponding dynamic comparison and returns a cvar. Unlike the C++ boolean operator, comparisons involving None and most ordinary values can propagate None instead of returning false.

operator>=

template<class T> bool operator>=(T&& x) const;
template<CNumeric T> friend bool operator>=(T x, const cvar& v);

Performs dynamic greater-or-equal comparison and returns a C++ boolean. Numeric types compare by numeric value, collections compare by their contents, and unlike ordinary categories use type ordering; object comparisons dispatch to the object.

GE

template<class T> cvar GE(T&& x) const;

Performs the corresponding dynamic comparison and returns a cvar. Unlike the C++ boolean operator, comparisons involving None and most ordinary values can propagate None instead of returning false.

operator+

template<class T> cvar operator+(T&& x) const;
template<CNumeric T> friend cvar operator+(T x, const cvar& v);
friend cstr operator+(const char* s, const cvar& v);

Performs dynamic add arithmetic on numeric values or component-wise on compatible vectors. Unsupported operands raise CError; vector sizes must be compatible. Two string values concatenate.

operator-

template<class T> cvar operator-(T&& x) const;
cvar operator-() const;
template<CNumeric T> friend cvar operator-(T x, const cvar& v);

Performs dynamic sub arithmetic on numeric values or component-wise on compatible vectors. Unsupported operands raise CError; vector sizes must be compatible. The unary overload negates numeric values.

operator/

template<class T> cvar operator/(T&& x) const;
template<CNumeric T> friend cvar operator/(T x, const cvar& v);

Performs dynamic div arithmetic on numeric values or component-wise on compatible vectors. Unsupported operands raise CError; vector sizes must be compatible. Integral division truncates; use Div() for explicit zero-divisor checking.

Div

template<class T> cvar Div(T&& x) const;

Divides using dynamic numeric/vector dispatch while explicitly checking for a zero divisor and raising CError. Integral division retains integer division semantics.

operator%

template<class T> cvar operator%(T&& x) const;
template<CNumeric T> friend cvar operator%(T x, const cvar& v);

Performs dynamic mod arithmetic on numeric values or component-wise on compatible vectors. Unsupported operands raise CError; vector sizes must be compatible. Floating-point remainder uses std::fmod.

operator+=

template<class T> cvar& operator+=(T&& x);
template<CNumeric T> friend T& operator+=(T& x, const cvar& v);

Applies dynamic add arithmetic in place and returns this value. References modify their referent; compatible vectors are updated component by component.

operator-=

template<class T> cvar& operator-=(T&& x);
template<CNumeric T> friend T& operator-=(T& x, const cvar& v);

Applies dynamic sub arithmetic in place and returns this value. References modify their referent; compatible vectors are updated component by component.

operator*=

template<class T> cvar& operator*=(T&& x);
template<CNumeric T> friend T& operator*=(T& x, const cvar& v);

Applies dynamic mul arithmetic in place and returns this value. References modify their referent; compatible vectors are updated component by component.

operator/=

template<class T> cvar& operator/=(T&& x);
template<CNumeric T> friend T& operator/=(T& x, const cvar& v);

Applies dynamic div arithmetic in place and returns this value. References modify their referent; compatible vectors are updated component by component.

DivBy

template<class T> cvar& DivBy(T&& x);

Applies checked division to this value in place and returns it. A zero divisor raises CError.

operator%=

template<class T> cvar& operator%=(T&& x);
template<CNumeric T> friend T& operator%=(T& x, const cvar& v);

Applies dynamic mod arithmetic in place and returns this value. References modify their referent; compatible vectors are updated component by component.

operator!

cvar operator!() const;

Applies dynamic negation: None remains None, Null becomes true, and integers compare with zero. References forward, maps negate their # head, and objects dispatch Not; unsupported categories such as Float and String throw CError.

operator++

cvar operator++(int);
cvar& operator++();

Increments an Integer or Float in place, forwarding through a reference. Prefix returns the updated receiver and postfix returns the old value; objects dispatch Inc or PostInc.

operator--

cvar operator--(int);
cvar& operator--();

Decrements an Integer or Float in place, forwarding through a reference. Prefix returns the updated receiver and postfix returns the old value; objects dispatch Dec or PostDec.

cvar::cset_hash

struct cset_hash

Methods

cvar::csym

class csym

Types, constants & data

cstr name;

Methods

csym

template<CString T> csym(T&& name);
csym() noexcept;
csym(const csym&) = default;
csym(csym&&) = default;

Creates a named symbol and caches its name hash. After default construction, initialize the name and call rehash() before hash-based lookup.

rehash

void rehash() noexcept;

Refreshes the cached name hash after direct modification of the symbol name.

hash

chash_ref hash() const noexcept;

Returns the cached name hash. Direct edits to name require rehash() before this value is used.

operator<<

friend std::ostream& operator<<(std::ostream& ostr, const csym& s);

operator cstr&

operator cstr&();

Borrows the mutable symbol name. Call rehash() after editing it so dispatch uses the new spelling.

isSym

template<CString T> bool isSym(T&& s) const;

Compares the cached hash against a supplied symbol name. Keep the hash current after editing the public name.

memoryUsage

size_t memoryUsage() const noexcept;

Estimates the symbol’s memory footprint from its object size and allocated name capacity.

dump

__attribute__((used)) cstr dump() const;

Returns the symbol’s printable name without evaluating or resolving it.

cvar::cfunc

class cfunc

Types, constants & data

using iterator = cvec::iterator;
using const_iterator = cvec::const_iterator;
cstr name;
cvec args;

Methods

cfunc

cfunc();
template<CString T, class... Args> cfunc(T&& name, Args&&... args);
template<CString T> cfunc(T&& name, cvec&& args);
cfunc(const cfunc&) = default;
cfunc(cfunc&&) = default;

Creates an unevaluated named function node from supplied arguments. The name and arity are cached for dispatch; default-constructed nodes require initialization and rehash().

rehash

void rehash() noexcept;

Refreshes the cached dispatch hash after changing the name or argument count. The hash distinguishes arities up to 15; larger arities use the shared variable-arity hash.

hash

chash_ref hash() const noexcept;

Returns the cached name-and-arity dispatch hash. It is not a content hash of argument values.

operator<<

template<class T> cfunc& operator<<(T&& x);

Appends an argument and returns this function node. Call rehash() after changing the argument count before hash-based dispatch.

operator[]

cvar& operator[](size_t i) noexcept;
const cvar& operator[](size_t i) const noexcept;

Returns an argument by zero-based index. The index must be below the argument count.

begin

iterator begin() noexcept;
const_iterator begin() const noexcept;

end

iterator end() noexcept;
const_iterator end() const noexcept;

size

size_t size() const noexcept;

empty

bool empty() const noexcept;

clear

void clear() noexcept;

Removes all arguments but retains the function name. Call rehash() to refresh the resulting arity.

popBack

cvar popBack() noexcept;

Removes and returns the last argument; the argument vector must be nonempty. Refresh the dispatch hash after changing arity.

popFront

cvar popFront() noexcept;

Removes and returns the first argument; the argument vector must be nonempty. Refresh the dispatch hash after changing arity.

pushFront

template<class T> void pushFront(T&& x);

Prepends an argument without refreshing the cached dispatch hash. Call rehash() when construction or editing is complete.

span

cspan span() const noexcept;
cspan span(size_t start) const noexcept;
cspan span(size_t start, size_t endOffset) const noexcept;

Returns numeric argument indices with optional initial and trailing exclusions.

isFunc

template<CString T> bool isFunc(T&& f) const;
template<CString T> bool isFunc(T&& f, size_t arity) const;
template<CString T> bool isFunc(T&& f, size_t minArity, size_t maxArity) const;

Matches a function name, optionally with exact arity or an inclusive arity range. The exact-arity form uses the cached hash; the range form checks the argument count directly.

memoryUsage

size_t memoryUsage() const;

Estimates memory for the function node, its name, and its recursively owned argument values.

dump

__attribute__((used)) cstr dump() const;

Returns the stream-formatted function expression. No arguments are evaluated.

cvar::CExecutor

class CExecutor

Methods

execute

virtual cvar execute(const cfunc& f);

Override to execute a named function node and return its value. The default implementation raises CError because no execution behavior is supplied.

canExecute

virtual bool canExecute(const cfunc& f);

Reports whether this executor supports a function node. The default returns false; override alongside execute() when callers need capability checks.

fail

virtual cvar fail(const cfunc& f);

Reports an unsupported function by raising CError with its formatted expression. Executors can override the failure policy.

cvar::CObject

class CObject : public CExecutor

Methods

ref

void ref();

Adds one reference to this runtime object. Owning object-valued cvar instances call this automatically.

deref

bool deref();

Drops a reference and calls release() when the count reaches zero. A true result tells the owner to delete the object; this method does not itself perform deletion.

release

virtual bool release();

Called when the final runtime reference is removed. Return true to permit deletion, or false for an externally managed object; the default returns true.

memoryUsage

virtual size_t memoryUsage() const;

Reports the object’s memory contribution for value accounting. Override for derived objects with additional storage; the default reports the base object size.

operator+

cvar operator+(const cvar& v);

Dispatches Add with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator-

cvar operator-(const cvar& v);

Dispatches Sub with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator*

cvar operator*(const cvar& v);

Dispatches Mul with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator/

cvar operator/(const cvar& v);

Dispatches Div with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator%

cvar operator%(const cvar& v);

Dispatches Mod with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator+=

void operator+=(const cvar& v);

Dispatches AddBy with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator-=

void operator-=(const cvar& v);

Dispatches SubBy with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator*=

void operator*=(const cvar& v);

Dispatches MulBy with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator/=

void operator/=(const cvar& v);

Dispatches DivBy with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator%=

void operator%=(const cvar& v);

Dispatches ModBy with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator==

cvar operator==(const cvar& v);
friend cvar operator==(const cvar& a, CObject& b);

Dispatches EQ with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator!=

cvar operator!=(const cvar& v);
friend cvar operator!=(const cvar& a, CObject& b);

Dispatches NE with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator<

cvar operator<(const cvar& v);
friend cvar operator<(const cvar& a, CObject& b);

Dispatches LT with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator>

cvar operator>(const cvar& v);
friend cvar operator>(const cvar& a, CObject& b);

Dispatches GT with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator<=

cvar operator<=(const cvar& v);
friend cvar operator<=(const cvar& a, CObject& b);

Dispatches LE with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

operator>=

cvar operator>=(const cvar& v);
friend cvar operator>=(const cvar& a, CObject& b);

Dispatches GE with the operand as a function argument through execute(). The derived runtime object supplies the operation’s behavior.

cvar::CObjectFactory

Methods

CObjectFactory

template<CString T> CObjectFactory(T&& className);

Registers a factory under a class name; duplicate registration raises CError. The registry borrows the factory pointer, so registered factories must remain alive for later construction.

construct

template<CString T, class S> static CObject* construct(T&& className, S&& args);

Returns a newly constructed object, or nullptr when the class name has no registered factory.

create

virtual CObject* create(cvec&& args) = 0;

Implement this to construct an object from the supplied argument vector. construct() finds the registered factory and calls this hook.

cvar::VecItr

struct VecItr : public CObject

Types, constants & data

cvec::iterator itr{};
cvec* owner = nullptr;

cvar::SetItr

struct SetItr : public CObject

Types, constants & data

cset::iterator itr{};
cset* owner = nullptr;

cvar::MapItr

struct MapItr : public CObject

Types, constants & data

cmap::iterator itr{};
cmap* owner = nullptr;

cvar::MapItrPtr

struct MapItrPtr : public CObject

Types, constants & data

cmap::iterator* itr = nullptr;
cmap* owner = nullptr;

cvar::cvar_proxy

template<CString K> class cvar_proxy

Methods

cvar_proxy

cvar_proxy(cvar& v, K&& k);
cvar_proxy(const cvar_proxy& p) noexcept;
cvar_proxy(cvar_proxy&& p) noexcept;

Represents a deferred string-key lookup into a parent value. It may borrow both parent and key; neither lifetime is extended.

operator=

cvar& operator=(const cvar_proxy& p);
cvar& operator=(std::initializer_list<cvar> il);
template<class T> cvar& operator=(T&& x);

Assigns the resolved value into the parent map entry, including when the source is another proxy. It writes through the proxy rather than rebinding it.

operator const cvar&

operator const cvar&() const;

Resolves and borrows an existing map entry. Missing keys throw; this conversion does not insert a default value.

operator cvar&

operator cvar&();

Resolves and borrows an existing writable entry. Missing keys and attempts to modify a const parent throw.

get

cvar& get();
const cvar& get() const;
template<class T> decltype(auto) get();
template<class T> decltype(auto) get() const;

Resolves the indexed value. Missing entries and writes through a const parent are checked.

put

cvar& put();

Writes through the proxy to its parent; this is distinct from copying the proxy object.

operator<<

template<class T> cvar& operator<<(T&& x);
friend std::ostream& operator<<(std::ostream& ostr, const cvar_proxy& p);

Resolves the map entry and appends or inserts into its contained value using cvar::operator<<.

as

template<class T> decltype(auto) as();
template<class T> decltype(auto) as() const;

Resolves the entry and applies checked cvar::as<T>() access or conversion. Returned references borrow the stored entry.

is

template<class T> bool is();
template<class T> bool is() const;

Resolves the entry and tests its effective value category. This is not a key-existence test; use the parent’s has() for that.

operator[]

template<CString K2> cvar_proxy<K2> operator[](K2&& k);
template<CString K2> const cvar_proxy<K2> operator[](K2&& k) const;
cvar& operator[](size_t i);
const cvar& operator[](size_t i) const;

Resolves this entry and indexes the nested value. Nested proxies still depend on the lifetime of their parent storage.

at

template<CString K2> cvar& at(K2&& k);
template<CString K2> const cvar& at(K2&& k) const;

Resolves this entry and performs checked nested map lookup without inserting a missing nested key.

operator T

template<CArithmetic T> operator T() const;

Applies the corresponding cvar operation to the resolved entry. Converts to an arithmetic type using as<T>(), following references and supported conversions. Unsupported categories throw CError; narrowing does not add a separate range check.

operator cstr&

operator cstr&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cstr>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cstr&

operator const cstr&() const;

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cstr>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cvec&

operator cvec&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cvec>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cvec&

operator const cvec&() const;

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cvec>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cset&

operator cset&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cset>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cset&

operator const cset&() const;

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cset>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cmap&

operator cmap&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cmap>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cmap&

operator const cmap&() const;

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cmap>(). It does not create a copy; the owning value and any followed references must remain valid.

operator csym&

operator csym&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<csym>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const csym&

operator const csym&() const;

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<csym>(). It does not create a copy; the owning value and any followed references must remain valid.

operator cfunc&

operator cfunc&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cfunc>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const cfunc&

operator const cfunc&() const;

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<cfunc>(). It does not create a copy; the owning value and any followed references must remain valid.

operator CBuffer&

operator CBuffer&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<CBuffer>(). It does not create a copy; the owning value and any followed references must remain valid.

operator const CBuffer&

operator const CBuffer&();

Applies the corresponding cvar operation to the resolved entry. Provides checked borrowed access through as<CBuffer>(). It does not create a copy; the owning value and any followed references must remain valid.

cvar::Wrap

template<class T> struct Wrap : public CObject

Types, constants & data

std::decay_t<T> v;

Methods

Wrap

template<class U> explicit Wrap(U&& value);

Stores the native value inside a runtime object wrapper. Prefer cvar::wrap() to create the owning dynamic value and assign its kind code.

Free functions & types

Types, constants & data

using cvec = cvar::cvec;
using cmap = cvar::cmap;
using cset = cvar::cset;
using csym = cvar::csym;
using cfunc = cvar::cfunc;
using cargs = cvec;
using CObject = cvar::CObject;
inline const cvar cnull;
inline const cvar cNull;
inline const cvar cnone = cvar(ctag(cvar::None));
inline const cvar cNone = cvar(ctag(cvar::None));
template<class T> concept CFunc = CSame<T, cvar> || CSame<T, cfunc>;

Functions

exp

template<class T> requires(std::same_as<T, cvar>) inline double exp(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T exp(T a);

Computes e raised to the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

log

template<class T> requires(std::same_as<T, cvar>) inline double log(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T log(T a);

Computes the natural logarithm of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

log10

template<class T> requires(std::same_as<T, cvar>) inline double log10(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T log10(T a);

Computes the base-10 logarithm of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

pow

template<class T, class S> requires(std::same_as<T, cvar>) inline double pow(const T& a, const S& b);
template<class T> requires(!std::same_as<T, cvar>) inline T pow(T a, T b);

Computes exponentiation. A cvar base and exponent are converted to double, and the dynamic overload returns a double result.

sqrt

template<class T> requires(std::same_as<T, cvar>) inline double sqrt(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T sqrt(T a);

Computes the square root of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

sin

template<class T> requires(std::same_as<T, cvar>) inline double sin(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T sin(T a);

Computes sine for an angle in radians. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

cos

template<class T> requires(std::same_as<T, cvar>) inline double cos(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T cos(T a);

Computes cosine for an angle in radians. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

tan

template<class T> requires(std::same_as<T, cvar>) inline double tan(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T tan(T a);

Computes tangent for an angle in radians. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

asin

template<class T> requires(std::same_as<T, cvar>) inline double asin(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T asin(T a);

Computes inverse sine, returning an angle in radians. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

acos

template<class T> requires(std::same_as<T, cvar>) inline double acos(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T acos(T a);

Computes inverse cosine, returning an angle in radians. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

sinh

template<class T> requires(std::same_as<T, cvar>) inline double sinh(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T sinh(T a);

Computes the hyperbolic sine of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

cosh

template<class T> requires(std::same_as<T, cvar>) inline double cosh(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T cosh(T a);

Computes the hyperbolic cosine of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

tanh

template<class T> requires(std::same_as<T, cvar>) inline double tanh(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T tanh(T a);

Computes the hyperbolic tangent of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

asinh

template<class T> requires(std::same_as<T, cvar>) inline double asinh(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T asinh(T a);

Computes the inverse hyperbolic sine of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

acosh

template<class T> requires(std::same_as<T, cvar>) inline double acosh(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T acosh(T a);

Computes the inverse hyperbolic cosine of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

atanh

template<class T> requires(std::same_as<T, cvar>) inline double atanh(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T atanh(T a);

Computes the inverse hyperbolic tangent of the numeric argument. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

ceil

template<class T> requires(std::same_as<T, cvar>) inline double ceil(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T ceil(T a);

Rounds toward positive infinity. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

floor

template<class T> requires(std::same_as<T, cvar>) inline double floor(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T floor(T a);

Rounds toward negative infinity. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

round

template<class T> requires(std::same_as<T, cvar>) inline double round(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T round(T a);

Rounds to the nearest integer value, with halfway cases rounded away from zero. The cvar overload converts to double and returns a double; the ordinary arithmetic overload returns its declared numeric type.

abs

template<class T> requires(std::same_as<T, cvar>) inline cvar abs(const T& a);
template<class T> requires(!std::same_as<T, cvar>) inline T abs(T a);

Returns the absolute value. The dynamic overload preserves the numeric cvar category; ordinary arithmetic overloads return the supplied type.

max

template<class T> requires(std::same_as<T, cvar>) inline cvar max(const T& a, const T& b);

Returns the larger numeric cvar, converting the right operand to the left operand’s integer or floating type. A floating right operand is truncated when the left is Integer.

min

template<class T> requires(std::same_as<T, cvar>) inline cvar min(const T& a, const T& b);

Returns the smaller numeric cvar, converting the right operand to the left operand’s integer or floating type. A floating right operand is truncated when the left is Integer.

cStub

template<CString T> inline cvar cStub(T&& type);

Creates a map whose # entry is the supplied type name. Other fields can then be added using normal map indexing.

cPrecedence

template<CString K> inline constexpr int cPrecedence(K&& op, bool& left);
template<CString K> inline constexpr int cPrecedence(K&& op);

Returns the parser/generator precedence for a named operator node. The overload with left also reports associativity; smaller precedence numbers bind more tightly.

cTo

template<class T> T cTo(const cstr& s);

Parses a supported numeric type from a string using the corresponding standard conversion routine. Invalid input raises CError; trailing unparsed text and narrowing follow those routines’ behavior.

cFold

template<CString FS, CItems Items> cvar cFold(FS&& fs, const Items& items);
template<CString FS, CItems Items> cvar cFold(FS&& fs, Items&& items);

Builds a left-associated chain of two-argument function nodes over a nonempty collection. For [a,b,c] and name F, the result represents F(F(a,b),c); it does not execute the functions.

CHandler

class CHandler

Methods

handle

virtual bool handle(cvar& v) = 0;

Implement this callback to process a borrowed, mutable dynamic value and return an application-defined boolean result. The abstract base supplies no handling behavior.