Sol2: get_or<int>() compile error

Created on 13 Jan 2017  路  3Comments  路  Source: ThePhD/sol2

I'm making simple get_or from documentation(1:1), but it doesn't compile.

I'm using Microsoft Visual Studio 2015 (vc14 compiler) combined with lua 5.3
I tested some other functions, and everything except this works great.

Example:

sol::state lua;
int will_not_error2 = lua["abc"]["def"]["ghi"]["jklm"].get_or<int>(25);

Error:

1>------ Build started: Project: luaaTest, Configuration: Debug x64 ------
1>  main.cpp
1>projects\luaatest\luaatest\main.cpp(11): error C2668: 'sol::proxy<Table,std::tuple<const char (&)[4],const char (&)[4],const char (&)[4],const char (&)[5]>>::get_or': ambiguous call to overloaded function
1>          with
1>          [
1>              Table=sol::global_table &
1>          ]
1>  projects\luaatest\luaatest\sol\proxy.hpp(92): note: could be 'decltype(auto) sol::proxy<Table,std::tuple<const char (&)[4],const char (&)[4],const char (&)[4],const char (&)[5]>>::get_or<int,int>(D &&) const'
1>          with
1>          [
1>              Table=sol::global_table &,
1>              D=int
1>          ]
1>  projects\luaatest\luaatest\sol\proxy.hpp(82): note: or       'decltype(auto) sol::proxy<Table,std::tuple<const char (&)[4],const char (&)[4],const char (&)[4],const char (&)[5]>>::get_or<int>(T &&) const'
1>          with
1>          [
1>              Table=sol::global_table &,
1>              T=int
1>          ]
1>  projects\luaatest\luaatest\main.cpp(11): note: while trying to match the argument list '(int)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Bug.Well Shit Documentation

All 3 comments

Medical tests, so cannot respond now. However, looks similar to #278 - try fixes / knowledge there, and also let me know where in the docs you're looking so I can fix it when I get back.

I got it from here:
http://sol2.readthedocs.io/en/latest/tutorial/all-the-things.html
Just ctrl+f and type "get_or<"

Thanks for pointing it out to me. It's fixed in the docs now. Just remember that in the case where the default value's type is the same as what you want, there's no need to specify with <int>. I wish I could make it less ambiguous but that would require either making it so everyone specifies it all the time or making it so it shouldn't be specified all the time, and that's probably not flexible.

I'll have to find another place to add a note about that, to make it easier on people when they encounter this problem...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patlecat picture patlecat  路  7Comments

Erwsaym picture Erwsaym  路  4Comments

shohnwal picture shohnwal  路  10Comments

mrgreywater picture mrgreywater  路  4Comments

Moneyl picture Moneyl  路  10Comments