Havin' lots of derps these days. Fix #141

This commit is contained in:
ThePhD 2016-07-15 07:33:54 -04:00
parent 87eb901b01
commit 85daffaa00
2 changed files with 31 additions and 0 deletions

View File

@ -598,6 +598,17 @@ namespace sol {
template <>
struct lua_type_of<this_state> : std::integral_constant<type, type::none> {};
template <typename T>
struct lua_type_of<T, std::enable_if_t<
meta::all<
meta::has_begin_end<T>,
meta::neg<meta::any<
std::is_base_of<reference, T>,
std::is_base_of<stack_reference, T>
>>
>::value
>> : std::integral_constant<type, type::table> {};
} // detail
template <typename T>

View File

@ -553,3 +553,23 @@ TEST_CASE("tables/add", "Basic test to make sure the 'add' feature works") {
REQUIRE(val == bigvec[i]);
}
}
TEST_CASE("tables/returns", "make sure that even references to vectors are being serialized as tables") {
sol::state lua;
std::vector<int> v{ 1, 2, 3 };
lua.set_function("f", [&]() -> std::vector<int>& {
return v;
});
lua.script("x = f()");
sol::object x = lua["x"];
sol::type xt = x.get_type();
REQUIRE(xt == sol::type::table);
sol::table t = x;
bool matching;
matching = t[1] == 1;
REQUIRE(matching);
matching = t[2] == 2;
REQUIRE(matching);
matching = t[3] == 3;
REQUIRE(matching);
}