mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-06-15 08:26:16 +08:00
The cheatsheet's "preferred" syntax for binding overloaded free functions, fun<Ret(Args...)>(&overloaded), only worked on MSVC because the existing fun<T>(T&&) overload sets T to a function type when called explicitly, which produces a function rvalue-reference parameter that does not match a function pointer argument. Standards-conforming compilers (clang, GCC in some modes) correctly rejected it. Added two new fun overloads, parameterized on the explicitly-supplied function-type Signature and using std::type_identity_t to keep that parameter non-deducible, so they only participate in overload resolution when Signature is given explicitly. One accepts a free function pointer, the other a pointer-to-member, enabling both fun<Ret(Args...)>(&free_fn) and fun<Ret(Args...) cv>(&Class::method) to disambiguate overloads without resorting to static_cast. |
||
|---|---|---|
| .. | ||
| chaiscript | ||