Skip to content

Commit dd4ad0b

Browse files
authored
Update ITEM34.md
1 parent 8fc4771 commit dd4ad0b

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

ITEM34.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ auto setSoundL = [](Sound s) {
2828
using namespace std::chrono;
2929
3030
setAlarm(steady_clock::now() + hours(1),
31-
s,
32-
seconds(30));
31+
s,
32+
seconds(30));
3333
};
3434
```
3535

@@ -43,9 +43,9 @@ using namespace std::placeholders;
4343

4444
auto setSoundB =
4545
std::bind(setAlarm,
46-
steady_clock::now() + 1h,
47-
_1,
48-
30s);
46+
steady_clock::now() + 1h,
47+
_1,
48+
30s);
4949
```
5050
5151
- 첫번째로 setSoundL은 param 타입을 명시적으로 알 수 있는데 반해서 setSoundB를 호출할 때는 placeholder
@@ -66,11 +66,11 @@ using namespace std:: placeholders;
6666
6767
auto setSoundB =
6868
std::bind(setAlarm,
69-
std::bind(std::plus<steady_clock::time_point>(),
70-
steady_clock::now(),
71-
hours(1)),
72-
_1,
73-
seconds(30));
69+
std::bind(std::plus<steady_clock::time_point>(),
70+
steady_clock::now(),
71+
hours(1)),
72+
_1,
73+
seconds(30));
7474
```
7575

7676
다음으로 setAlarm이 오버로딩 되는 경우를 더 생각해 보자. 여기서 추가적인 문제가 발생한다.
@@ -92,11 +92,11 @@ using SetAlarm3ParamType = void(*)(Time t, Sound s, Duration d);
9292
9393
auto setSoundB =
9494
std::bind(static_cast<SetAlarm3ParamType>(setAlarm),
95-
std::bind(std::plus<>,
96-
steady_clock::now(),
97-
h1),
98-
_1,
99-
30s);
95+
std::bind(std::plus<>,
96+
steady_clock::now(),
97+
h1),
98+
_1,
99+
30s);
100100
```
101101

102102
- 여기서 한가지 차이점이 또 발생한다. Lamda의 경우 내부에서 호출하는 setAlarm이 일반 함수이기 때문에 컴파
@@ -121,8 +121,8 @@ using namespace std::placeholders;
121121
122122
auto betweenB =
123123
std::bind(std::logical_and<bool>(),
124-
std::bind(std::less_euqal<int>(), lowVal, _1),
125-
std::bind(std::less_equal<int>(), _1, highVal));
124+
std::bind(std::less_euqal<int>(), lowVal, _1),
125+
std::bind(std::less_equal<int>(), _1, highVal));
126126
```
127127

128128
Lamda 버전이 더 짧을뿐 아니라 더 이해하기 쉽고 유지보수하기 쉽다는데 동의하기 바란다. :)
@@ -133,7 +133,7 @@ Lamda 버전이 더 짧을뿐 아니라 더 이해하기 쉽고 유지보수하
133133
enum class CompLevel { Low, Normal, High };
134134

135135
Widget compress(const Widget& w,
136-
CompLevel lev);
136+
CompLevel lev);
137137

138138
Widget w;
139139

@@ -200,5 +200,5 @@ C++11 lamda에서는 이렇게 할 수 있는 방법이 없었다. 하지만 C++
200200
201201
```c++
202202
auto boundPW = [pw](const auto& param)
203-
{ pw(param); };
203+
{ pw(param); };
204204
```

0 commit comments

Comments
 (0)