The value of a C++ variant exposed in Lua can be modified.
Elements of a C++ vector exposed in Lua can usually be modified.
But elements of a vector of variants seem to be returned by value instead of reference, so cannot be modified in place.
The following code passes three copies of a vector into Lua, and attempts to modify them by each of the above routes (in a variant, in a vector, in a vector of variants).
The expected results are 3, 3, 3: the actual results are 3, 3, 2, indicating that the table insertion is modifying a copy of variantVec[1] rather than the value held in the vector.
Is there any way I can persuade Sol to give Lua access by reference in the third case?
(This is using Sol 3.3.0 with Lua 5.3.3 in C++17 compiled by XCode 10.3 on MacOS 10.14.6.)
The value of a C++ variant exposed in Lua can be modified. Elements of a C++ vector exposed in Lua can usually be modified. But elements of a vector of variants seem to be returned by value instead of reference, so cannot be modified in place.
The following code passes three copies of a vector into Lua, and attempts to modify them by each of the above routes (in a variant, in a vector, in a vector of variants).
The expected results are 3, 3, 3: the actual results are 3, 3, 2, indicating that the table insertion is modifying a copy of
variantVec[1]
rather than the value held in the vector.Is there any way I can persuade Sol to give Lua access by reference in the third case?
(This is using Sol 3.3.0 with Lua 5.3.3 in C++17 compiled by XCode 10.3 on MacOS 10.14.6.)