| 12 | } |
| 13 | |
| 14 | int main() { |
| 15 | std::cout << "=== overloading ===" << std::endl; |
| 16 | |
| 17 | sol::state lua; |
| 18 | lua.open_libraries(sol::lib::base); |
| 19 | |
| 20 | // you can overload functions |
| 21 | // just pass in the different functions |
| 22 | // you want to pack into a single name: |
| 23 | // make SURE they take different types! |
| 24 | |
| 25 | lua.set_function("func", sol::overload([](int x) { return x; }, make_string, my_add)); |
| 26 | |
| 27 | // All these functions are now overloaded through "func" |
| 28 | lua.script(R"( |
| 29 | print(func(1)) |
| 30 | print(func("bark")) |
| 31 | print(func(1,2)) |
| 32 | )"); |
| 33 | |
| 34 | std::cout << std::endl; |
| 35 | |
| 36 | return 0; |
| 37 | } |
nothing calls this directly
no test coverage detected