Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
non-deduced context
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> #include <functional> template<class T, class U> int adapter1(T t, U u, int (*f)(T, U)) { return f(t, u); } template<class T, class U> int adapter2(T t, U u, std::function<int(T,U)> f) { return f(t, u); } template<class T> using func = typename std::common_type<T>::type; template<class T, class U> int adapter3(T t, U u, func<int(T,U)> f) { return f(t, u); } int main() { auto l = [](int t, double u)->int{ return t + u; }; int t = 9; double u = 8.9; std::cout << adapter1(t, u, +l); // ok except visual studio //std::cout << adapter2(t, u, l); // fails everywhere std::cout << adapter3(t, u, l); // ok everywhere }
run
|
edit
|
history
|
help
0
wellformed number
Namespace scope qualifier
Fun with Pointers #2
Apple is not convertible to itself (clang 3.8.0)
ArrayList Example Starter Code 2
Optional conversions
chakib
Non type template argument
cv5_class
Result of not joining thread in main()