diff --git a/docs/source/api/usertype.rst b/docs/source/api/usertype.rst index d91b6401..9f0a4f99 100644 --- a/docs/source/api/usertype.rst +++ b/docs/source/api/usertype.rst @@ -92,7 +92,7 @@ If you don't specify any constructor options at all and the type is `default_con - If you pass the ``constructors<...>`` argument first when constructing the usertype, then it will automatically be given a ``"{name}"`` of ``"new"`` * ``"{name}", sol::initializers( func1, func2, ... )`` - Used to handle *initializer functions* that need to initialize the memory itself (but not actually allocate the memory, since that comes as a userdata block from Lua) - - Given one or more functions, provides an overloaded Lua function for creating a the specified type + - Given one or more functions, provides an overloaded Lua function for creating the specified type + The function must have the argument signature ``func( T*, Arguments... )`` or ``func( T&, Arguments... )``, where the pointer or reference will point to a place of allocated memory that has an uninitialized ``T``. Note that Lua controls the memory, so performing a ``new`` and setting it to the ``T*`` or ``T&`` is a bad idea: instead, use ``placement new`` to invoke a constructor, or deal with the memory exactly as you see fit * ``{anything}, sol::factories( func1, func2, ... )`` - Used to indicate that a factory function (e.g., something that produces a ``std::unique_ptr``, ``std::shared_ptr``, ``T``, or similar) will be creating the object type