diff --git a/sol/types.hpp b/sol/types.hpp index 4bc12d7b..c37a8850 100644 --- a/sol/types.hpp +++ b/sol/types.hpp @@ -598,6 +598,17 @@ namespace sol { template <> struct lua_type_of : std::integral_constant {}; + + template + struct lua_type_of, + meta::neg, + std::is_base_of + >> + >::value + >> : std::integral_constant {}; } // detail template diff --git a/test_tables.cpp b/test_tables.cpp index da87b54c..fc478fd8 100644 --- a/test_tables.cpp +++ b/test_tables.cpp @@ -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 v{ 1, 2, 3 }; + lua.set_function("f", [&]() -> std::vector& { + 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); +}