Class DefaultFactory#

Inheritance Relationships#

Base Type#

Class Documentation#

class DefaultFactory : public tvm::ffi::reflection::InfoTrait#

Trait that can be used to set field default factory.

A default factory is a callable () -> Any that is invoked each time a default value is needed, producing a fresh value. This is important for mutable defaults (e.g., Array, Map) to avoid aliasing.

Public Functions

inline explicit DefaultFactory(Function factory)#

Constructor.

Parameters:

factory – The factory function to be called to produce default values.

inline void Apply(TVMFFIFieldInfo *info) const#

Apply the default factory to the field info.

Parameters:

info – The field info.