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.
Co-authored-by: leftibot <leftibot@users.noreply.github.com>
I initially tried to use the existing .clang-format file,
but it does not match the code style (at least with clang-format 11)
and the formatting is not consistent across files.
Therefore, I decided to rewrite the .clang-format with some personal
preferences.
Used command
find . -iname "*.hpp" -o -iname "*.cpp" | xargs clang-format -i -style=file
Closes#348
This works by taking into account the fact that `noexcept` is now part
of the type system in C++17. However, this would conflict with pre-C++17
compilers, so I have added a feature macro around it
The std::is_member_function_pointer<> template is broken on this version
of the libc++ standard library for const member functions.
To get ChaiScript to work with this, we had to work around the use of
automatically generated std::function wrappers in many cases. This
actually cleaned up the code in a few places and muddied it up in one.