sol2/docs/source/api/protect.rst
ThePhD 486086ffe0
fix up CMake files once more, and hopefully prepare for a new test coverage paradigm
notably, test normal + single + generated + Lua 5.3.5 only once,
then only run the runtime_test and compile_test for normal for all other permutations to help increase text matrix throughput
2018-12-27 02:17:25 -05:00

15 lines
619 B
ReStructuredText

protect
=======
*routine to mark a function / variable as requiring safety*
.. code-block:: cpp
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: