Skip to content

Latest commit

 

History

History
14 lines (9 loc) · 619 Bytes

protect.rst

File metadata and controls

14 lines (9 loc) · 619 Bytes

protect

routine to mark a function / variable as requiring safety

template <typename T>
auto protect( T&& value );

sol::protect( my_func ) allows you to protect a function call or member variable call when it is being set to Lua. It can be used with usertypes or when just setting a function into sol. Below is an example that demonstrates that a call that would normally not error without :doc:`Safety features turned on<../safety>` that instead errors and makes the Lua safety-call wrapper pcall fail:

.. literalinclude:: ../../../examples/source/protect.cpp
        :linenos: