VC++ Compat again.

This commit is contained in:
ThePhD 2013-12-13 20:09:51 -05:00
parent 4dab754b86
commit 9624dd93e7
4 changed files with 28 additions and 25 deletions

View File

@ -62,13 +62,13 @@ public:
function& operator=(const function&) = default;
template<typename... Args>
void operator()( Args&&... args ) {
call<>(std::forward<Args>(args)... );
void operator()(Args&&... args) {
call<>(std::forward<Args>(args)...);
}
template<typename... Ret, typename... Args>
auto operator()( types<Ret...>, Args&&... args ) {
return call<Ret...>(std::forward<Args>(args)... );
auto operator()(types<Ret...>, Args&&... args) {
return call<Ret...>(std::forward<Args>(args)...);
}
template<typename... Ret, typename... Args>

View File

@ -41,7 +41,7 @@ T* get_ptr(T* val) {
} // detail
class table : virtual public reference {
template<typename T, typename U> struct proxy;
template<typename Table, typename T> struct proxy;
public:
table() noexcept : reference() {}
table(lua_State* L, int index = -1) : reference(L, index) {

View File

@ -72,56 +72,56 @@ template<typename TFuncSignature>
struct function_traits;
template<typename T, typename R, typename... Args>
struct function_traits<R( T::* )( Args... )> {
static const std::size_t arity = sizeof...( Args );
struct function_traits<R(T::*)(Args...)> {
static const std::size_t arity = sizeof...(Args);
static const bool is_member_function = true;
typedef std::tuple<Args...> arg_tuple_type;
typedef types<Args...> args_type;
typedef R( T::* function_pointer_type )( Args... );
typedef R(T::* function_pointer_type)(Args...);
typedef typename std::remove_pointer<function_pointer_type>::type function_type;
typedef R( *free_function_pointer_type )( Args... );
typedef R(*free_function_pointer_type)(Args...);
typedef R return_type;
template<std::size_t i>
using arg = typename std::tuple_element<i, arg_tuple_type>::type;
};
template<typename T, typename R, typename... Args>
struct function_traits<R( T::* )( Args... ) const> {
static const std::size_t arity = sizeof...( Args );
struct function_traits<R(T::*)(Args...) const> {
static const std::size_t arity = sizeof...(Args);
static const bool is_member_function = true;
typedef std::tuple<Args...> arg_tuple_type;
typedef types<Args...> args_type;
typedef R( T::* function_pointer_type )( Args... );
typedef R(T::* function_pointer_type)(Args...);
typedef typename std::remove_pointer<function_pointer_type>::type function_type;
typedef R( *free_function_pointer_type )( Args... );
typedef R(*free_function_pointer_type)(Args...);
typedef R return_type;
template<std::size_t i>
using arg = typename std::tuple_element<i, arg_tuple_type>::type;
};
template<typename R, typename... Args>
struct function_traits<R( Args... )> {
static const std::size_t arity = sizeof...( Args );
struct function_traits<R(Args...)> {
static const std::size_t arity = sizeof...(Args);
static const bool is_member_function = false;
typedef std::tuple<Args...> arg_tuple_type;
typedef types<Args...> args_type;
typedef R( function_type )( Args... );
typedef R( *function_pointer_type )( Args... );
typedef R( *free_function_pointer_type )( Args... );
typedef R(function_type)(Args...);
typedef R(*function_pointer_type)(Args...);
typedef R(*free_function_pointer_type)(Args...);
typedef R return_type;
template<std::size_t i>
using arg = typename std::tuple_element<i, arg_tuple_type>::type;
};
template<typename R, typename... Args>
struct function_traits<R( *)( Args... )> {
static const std::size_t arity = sizeof...( Args );
struct function_traits<R(*)(Args...)> {
static const std::size_t arity = sizeof...(Args);
static const bool is_member_function = false;
typedef std::tuple<Args...> arg_tuple_type;
typedef types<Args...> args_type;
typedef R( function_type )( Args... );
typedef R( *function_pointer_type )( Args... );
typedef R( *free_function_pointer_type )( Args... );
typedef R(function_type)(Args...);
typedef R(*function_pointer_type)(Args...);
typedef R(*free_function_pointer_type)(Args...);
typedef R return_type;
template<std::size_t i>
using arg = typename std::tuple_element<i, arg_tuple_type>::type;

View File

@ -81,7 +81,10 @@ TEST_CASE("simple/callWithParameters", "Lua function is called with a few parame
REQUIRE_NOTHROW(lua.script("function my_add(i, j, k) return i + j + k end"));
auto f = lua.get<sol::function>("my_add");
REQUIRE_NOTHROW(lua.script("function my_nothing(i, j, k) end"));
auto fvoid = lua.get<sol::function>("my_nothing");
int a;
REQUIRE_NOTHROW(fvoid(1, 2, 3));
REQUIRE_NOTHROW(a = f.call<int>(1, 2, 3));
REQUIRE(a == 6);
REQUIRE_THROWS(a = f.call<int>(1, 2, "arf"));
@ -166,7 +169,7 @@ TEST_CASE("tables/functions_variables", "Check if tables and function calls work
std::cout << "stateless lambda()" << std::endl;
return "test";
}
);
);
REQUIRE_NOTHROW(run_script(lua));
lua.get<sol::table>("os").set_function("fun", &free_function);
@ -184,7 +187,7 @@ TEST_CASE("tables/functions_variables", "Check if tables and function calls work
std::cout << "stateless lambda()" << std::endl;
return "test";
}
);
);
REQUIRE_NOTHROW(run_script(lua));
// r-value, cannot optomize