Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
BucketSort
List comprehension in C++ using functional patterns
Zadanie Dejwu
Tree Traversal and Node
First
Error
C++ Operator Overloading
ArrayList Example Starter Code 2
U2
chakib
Please log in to post a comment.