The current question now is that we hope to get a template parameter t in a compile period whether T is not a pointer or a reference? Fortunately, the Boost library has provided such a function, and Boost provides a set of type_traits that allows us to get the type of template parameter T during the compile period.
You can download the BOOST library from http://boost.sourceforge.net/index.sourceforge.net/index.sourceforge.net/index.htm; we need a group of Boost's Type_Traits.
After downloading the Boost library, set the included path, let us start modifying our Call function, making appropriate changes to pointers and references. After having a Boost library, test a template parameter T is a pointer or a reference to another simple:
#include
Template
Now we have been able to get a BOOL value. If this value is true, we do not try to get such a parameter from the Lua stack, but first give it to the call function processing, then hand it over to Lua, and return At the time, it is a copy of the content referring to this pointer. If we leave, we only give it to the call function as a parameter.
In order to be able to do a static assignment of the compile period, we use the overload mechanism of the function. First, we need to define a BOOL to type mapping to distinguish between parameters:
Template
For the sake of clarity, we make a Typedef in both forms:
TypedEf Bool2Type
For a parameter, if its flag is ResultType, then it will be handed over to Lua, if it is a second form, then it is only given to the modulated function.
Now we have to provide two versions of the _call function for a Call function to distinguish between its pointer parameters:
Template
Template
Now we can handle directly to _call in the Call function:
Template