Hi, I want to use get_or to get a value out of a table or if missing use a default, but I'm having some trouble making it work for a specific use case. To my understanding, the following should work just fine:
struct pos { int x, y; };
auto p = lua_table.get_or("myPos", pos{0, 0});
However, it fails to compile in MSVC, GCC and Clang, whereas the following works just fine:
struct pos { int x, y; };
pos alt{0, 0};
auto p = lua_table.get_or("myPos", alt);
Is this the intended behavior or is it a bug? If this is intended, I think it's best if we get a static_assert saying that our "alternative" should be a lvalue (I guess?), it should be more helpful than the current state of things.
Here's a godbolt link with a complete example.
Hi, I want to use
get_orto get a value out of a table or if missing use a default, but I'm having some trouble making it work for a specific use case. To my understanding, the following should work just fine:However, it fails to compile in MSVC, GCC and Clang, whereas the following works just fine:
Is this the intended behavior or is it a bug? If this is intended, I think it's best if we get a
static_assertsaying that our "alternative" should be a lvalue (I guess?), it should be more helpful than the current state of things.Here's a godbolt link with a complete example.