hi, i have a problem with following code
#include <iostream>
#include <print>
#include <typeinfo>
template <typename T> std::string type_name();
template <typename... T>
void showNames(T... a) {
((std::cout
<< typeid(a).name() << " "
<< " " <<
a << std::endl
), ...);
}
double f(int x, double y, const int &z, int &w){
w += 2;
std::cout << x << " " << y << " " << z << " " << w << std::endl;
return (x * y - z * w);
}
template <class F>
class Proxy {
public:
F f;
Proxy(F f) : f(f) {}
auto operator()(auto&&... a) {
return f(a...);
}
};
int main(){
int x = 4;
const int y = 8;
showNames(x, 4.5, y, f);
showNames(1, 1.0f, 1.0, 1LL, &x, &y);
//auto p = make_proxy(f);
auto p = Proxy(f); /// with C++ 17
auto result1 = p(12, 5.1, y, x);
std::cout << "result1 = " << result1 << std::endl;
auto result2 = p(12, 5.1, y, x);
std::cout << "result2 = " << result2 << std::endl;
auto result3 = p(3, 3, 5, x);
std::cout << "result3 = " << result3 << std::endl;
//auto g = make_proxy([](int &&x, int & y){ y = x; return y; }) ;
auto g = Proxy([](int &&x, int & y) { y = x; return y; }) ; // with C++ 17
std::cout << g(5, x) << std::endl;
std::cout << "x = " << x << std::endl;
return 0;
}
I get a following error, how can i fix it?