We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include <type_traits> #include <functional> template <typename Ret, typename... Arg, typename... Param> constexpr auto strict_invoke(Ret (*f)(Arg...), Param&&... param) noexcept(false) -> Ret requires( std::is_same_v<std::remove_cvref_t<Arg>, std::remove_cvref_t<Param>> && ...) && std::is_invocable_v<decltype(f), decltype(param)...> { return f(std::forward<Param>(param)...); } double add(double lhs, double rhs) { return lhs + rhs; } int main() { add(2.3f, 1.3f); // works add(2, 1); // works //strict_invoke(&add, 2.3f, 1.3f); // fails, requires conversion strict_invoke(&add, 1.3, 1.3); // works //strict_invoke(&add, 1, 2); // fails, requires conversion }
https://compiler-explorer.com/z/8sxMd1aj5
The text was updated successfully, but these errors were encountered:
No branches or pull requests
https://compiler-explorer.com/z/8sxMd1aj5
The text was updated successfully, but these errors were encountered: