User:MikeMol/playground
(Redirected from User:Short Circuit/playground)
<cpp>class CSquare : unary_function<double, void> {
double operator(double x) {return x*x;}
}
void func() {
vector<double> src(100), squared(100); iota(src.begin(), src.end(), 1); transform(src.begin(), src.end(), squared.begin(), CSquare());
} </cpp>
<cpp>void func() {
vector<double> src(100), squared(100); iota(src.begin(), src.end(), 1); transform(src.begin(), src.end(), squared.begin(), [](double x){return x*x;});
} </cpp>