Template Struct AttrKey#

Struct Documentation#

template<typename T>
struct AttrKey#

A typed attribute name. Null-terminated name storage must outlive the key.

// In namespace tvm::ffi:
namespace type_attr {
inline constexpr reflection::AttrKey<bool> kSerializable{"example.serializable"};
}
reflection::TypeAttrDef<MyObject>().attr(type_attr::kSerializable, true);

Public Types

using ValueType = T#

The value type associated with this key.

Public Functions

inline std::optional<ValueType> ValueFrom(AnyView value) const#

Extract a present value strictly; None denotes an absent entry.

Note

Borrowed results remain valid only while the source value’s owner remains alive.

Throws:

Error – if a present value has the wrong type. No fallback conversion is run.

Public Members

const char *name#

Borrowed null-terminated attribute name; its storage must outlive the key.