mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
6c40c559e3
change how type T is gleaned from destructors and constructors in case of new syntax add a hell of a lot more examples, update and clean documentation
15 lines
612 B
ReStructuredText
15 lines
612 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/protect.cpp
|
|
:linenos:
|