|
welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
|
The stored form of a no_reassign mark: the languages a data member is bound read-only** for, independent of whether its C++ type is const. More...
#include <welder/annotations.hpp>
Public Member Functions | |
| template<class... Ls> | |
| consteval no_reassign_spec | operator() (Ls... ls) const |
| Scope the read-only binding to specific languages. | |
Public Attributes | |
| unsigned | mask = 0 |
| The languages to bind read-only for; 0 == all languages. | |
The stored form of a no_reassign mark: the languages a data member is bound read-only** for, independent of whether its C++ type is const.
welder decides a data member's target-language mutability from its const-ness — a const member binds read-only, a mutable one read/write. no_reassign forces the read-only binding on an otherwise-mutable member: the target language may still mutate the object in place (a read-only binding hands out a live reference, so obj.items.append(x) writes through to the C++ object) but cannot rebind** the attribute to a different object (obj.items = [...] is rejected). It is exactly the binding a const member already gets — pybind11 def_readonly, nanobind def_ro, sol2 sol::readonly, LuaBridge3 a getter-only addProperty, and a (read-only) note in the LuaCATS stub — asked for without making the C++ member const. The motivating case is a mutable STL container member (std::vector<Entity>): keep it appendable while forbidding a whole-list reassignment (which for an opaque container would otherwise need an ugly mangled type).
Usable bare (all languages) or called with languages to scope it, like exclude_spec:
Repeated annotations union their languages. A no-op on an already-const member (which is read-only regardless).
Definition at line 274 of file annotations.hpp.
|
inlineconsteval |
Scope the read-only binding to specific languages.
| Ls | the language enum types (deduced). |
| ls | the languages to bind the member read-only for. |
Definition at line 282 of file annotations.hpp.
References welder::lang_mask().
| unsigned welder::detail::no_reassign_spec::mask = 0 |
The languages to bind read-only for; 0 == all languages.
Definition at line 275 of file annotations.hpp.