Template Struct init#

Struct Documentation#

template<typename ...Args>
struct init#

Helper class to register a constructor method for object types.

This helper is used with ObjectDef::def() to register an __init__ method that constructs an object instance with the specified argument types.

Example usage:

class ExampleObject : public Object {
 public:
   int64_t v_i64;
   int32_t v_i32;

   ExampleObject(int64_t v_i64, int32_t v_i32) : v_i64(v_i64), v_i32(v_i32) {}
   TVM_FFI_DECLARE_OBJECT_INFO("example.ExampleObject", ExampleObject, Object);
};

// Register the constructor
refl::ObjectDef<ExampleObject>()
   .def(refl::init<int64_t, int32_t>());

Note

The object type is automatically deduced from the ObjectDef context.

Template Parameters:

Args – The argument types for the constructor.

Public Functions

constexpr init() noexcept = default#

Constructor.

Friends

friend class ObjectDef