Google C++ Style Guidegoals of the style guide as we currently see them are as follows: 1 Style rules should pull their weight The benefit of a style rule must be large enough to justify asking all of our engineers to remember functions as arguments. For example: std::sort(v.begin(), v.end(), [](int x, int y) { return Weight(x) < Weight(y); }); They further allow capturing variables from the enclosing scope either explicitly or reference capture: int weight = 3; int sum = 0; // Captures `weight` by value and `sum` by reference. std::for_each(v.begin(), v.end(), [weight, &sum](int x) { sum += weight * x; }); Default captures0 码力 | 83 页 | 238.71 KB | 1 年前3
共 1 条
- 1













