We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ec89adf commit d14532eCopy full SHA for d14532e
docs/cpp_tricks.md
@@ -625,7 +625,7 @@ void calc_average() {
625
例如字符串切片函数典型的一种实现中,因为“尾巴”的伺候和“主体”的伺候,就会产生重复代码:
626
627
```cpp
628
-vector<string> spilt(string str) {
+vector<string> split(string str) {
629
vector<string> list;
630
string last;
631
for (char c: str) {
@@ -644,7 +644,7 @@ vector<string> spilt(string str) {
644
上面的代码中重复的部分 `list.push_back(last);` 可以用 Lambda 复用,把重复的操作封装成局部的 Lambda:
645
646
647
648
649
650
auto push_last = [&] {
0 commit comments