From bd3fe0cac583739bc0d7c4b5c8f301bb350abca0 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Fri, 30 Aug 2019 00:19:31 -0400 Subject: Renamed lib to deps so github will ignore it for language stats --- deps/sol2/docs/source/api/protect.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 deps/sol2/docs/source/api/protect.rst (limited to 'deps/sol2/docs/source/api/protect.rst') diff --git a/deps/sol2/docs/source/api/protect.rst b/deps/sol2/docs/source/api/protect.rst new file mode 100644 index 0000000..b7fad2d --- /dev/null +++ b/deps/sol2/docs/source/api/protect.rst @@ -0,0 +1,14 @@ +protect +======= +*routine to mark a function / variable as requiring safety* + + +.. code-block:: cpp + + template + 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: -- cgit v1.2.3