È
胡宇光
Think about the following code:
void func() {
...
A a = b? f1(x,y,z):f2(o,p,q);
...
}
1, class A doesn't not have default constructor.
2, x,y,z,o,p,q and the f1,f2 name are very long.
How can I make the code shorter?
If 1x is allowed, maybe I can write
auto F1 = [&]() {return f1(x,y,z);}
auto F2 = [&]() {return f2(o,p,q);}
A a = b? F1():F2();
If use c++ 03, how can I make the code shorter?
void func() {
...
A a = b? f1(x,y,z):f2(o,p,q);
...
}
1, class A doesn't not have default constructor.
2, x,y,z,o,p,q and the f1,f2 name are very long.
How can I make the code shorter?
If 1x is allowed, maybe I can write
auto F1 = [&]() {return f1(x,y,z);}
auto F2 = [&]() {return f2(o,p,q);}
A a = b? F1():F2();
If use c++ 03, how can I make the code shorter?