Skip to content

Commit 48aec46

Browse files
committed
format {foo} => { foo }
modified: format.rb modified: ../ch03/README.md modified: ../ch04/README.md modified: ../ch05/README.md modified: ../ch05/ex5_14.cpp modified: ../ch05/ex5_17.cpp modified: ../ch06/README.md modified: ../ch06/ex6_23.cpp modified: ../ch07/README.md modified: ../ch07/ex7_11.h modified: ../ch07/ex7_12.h modified: ../ch07/ex7_15.h modified: ../ch07/ex7_21.h modified: ../ch07/ex7_22.h modified: ../ch07/ex7_23.h modified: ../ch07/ex7_24.h modified: ../ch07/ex7_26.h modified: ../ch07/ex7_27.h modified: ../ch07/ex7_32.h modified: ../ch07/ex7_50.h modified: ../ch09/README.md modified: ../ch09/ex9_41.cpp modified: ../ch09/ex9_47_1.cpp modified: ../ch09/ex9_47_2.cpp modified: ../ch09/ex9_52.cpp modified: ../ch10/README.md modified: ../ch10/ex10_05.cpp modified: ../ch10/ex10_12.cpp modified: ../ch10/ex10_17.cpp modified: ../ch10/ex10_22.cpp modified: ../ch10/ex10_27.cpp modified: ../ch10/ex10_28.cpp modified: ../ch10/ex10_32.cpp modified: ../ch11/README.md modified: ../ch11/ex11_12_13.cpp modified: ../ch11/ex11_20.cpp modified: ../ch11/ex11_27_28_29_30.cpp modified: ../ch11/ex11_31.cpp modified: ../ch11/ex11_32.cpp modified: ../ch11/ex11_8.cpp modified: ../ch12/README.md modified: ../ch12/ex12_02_TEST.cpp modified: ../ch12/ex12_06.cpp modified: ../ch12/ex12_15.cpp modified: ../ch12/ex12_17_18.cpp modified: ../ch12/ex12_19.h modified: ../ch12/ex12_22.h modified: ../ch12/ex12_23.cpp modified: ../ch12/ex12_24.cpp modified: ../ch12/ex12_27_30.cpp modified: ../ch12/ex12_27_30.h modified: ../ch12/ex12_28.cpp modified: ../ch12/ex12_32.cpp modified: ../ch12/ex12_32.h modified: ../ch12/ex12_33.cpp modified: ../ch12/ex12_33.h modified: ../ch13/README.md modified: ../ch13/ex13_13.cpp modified: ../ch13/ex13_26.h modified: ../ch13/ex13_28.h modified: ../ch13/ex13_34_36_37.h modified: ../ch13/ex13_39.h modified: ../ch13/ex13_40.h modified: ../ch13/ex13_42_StrVec.h modified: ../ch13/ex13_42_TextQuery.h modified: ../ch13/ex13_44_47.h modified: ../ch13/ex13_49_Message.h modified: ../ch13/ex13_49_StrVec.h modified: ../ch13/ex13_49_String.h modified: ../ch14/ex14_02.h modified: ../ch14/ex14_07.h modified: ../ch14/ex14_16_StrBlob.h modified: ../ch14/ex14_16_StrVec.h modified: ../ch14/ex14_16_String.h modified: ../ch14/ex14_18_StrBlob.h modified: ../ch14/ex14_18_StrVec.h modified: ../ch14/ex14_18_StrVecMain.cpp modified: ../ch14/ex14_18_String.h modified: ../ch14/ex14_22.h modified: ../ch14/ex14_23.h modified: ../ch14/ex14_24.cpp modified: ../ch14/ex14_24.h modified: ../ch14/ex14_26_StrBlob.h modified: ../ch14/ex14_26_StrVec.h modified: ../ch14/ex14_26_String.h modified: ../ch14/ex14_27_28_StrBlob.h modified: ../ch14/ex14_30_StrBlob.h modified: ../ch14/ex14_32.cpp modified: ../ch14/ex14_32.h modified: ../ch14/ex14_37.cpp modified: ../ch14/ex14_38_39.cpp modified: ../ch14/ex14_40.cpp modified: ../ch14/ex14_42.cpp modified: ../ch14/ex14_44.cpp modified: ../ch14/ex14_45.h modified: ../ch14/ex14_49.cpp modified: ../ch14/ex14_49.h modified: ../ch15/ex15.23.cpp modified: ../ch15/ex15.26/bulk_quote.h modified: ../ch15/ex15.27/bulk_quote.h modified: ../ch15/ex15.28.29/bulk_quote.h modified: ../ch15/ex15.30/basket.h modified: ../ch15/ex15.30/bulk_quote.h modified: ../ch15/ex15.30/quote.h modified: ../ch15/ex15.31.32.33.cpp modified: ../ch15/ex15.42_b/andquery.h modified: ../ch15/ex15.42_b/binaryquery.h modified: ../ch15/ex15.42_b/notquery.h modified: ../ch15/ex15.42_b/orquery.h modified: ../ch15/ex15.42_b/query.h modified: ../ch15/ex15.42_b/queryresult.h modified: ../ch15/ex15.42_b/wordquery.h modified: ../ch15/ex15.42_c/andquery.h modified: ../ch15/ex15.42_c/binaryquery.h modified: ../ch15/ex15.42_c/notquery.h modified: ../ch15/ex15.42_c/orquery.h modified: ../ch15/ex15.42_c/query.h modified: ../ch15/ex15.42_c/queryresult.h modified: ../ch15/ex15.42_c/wordquery.h modified: ../ch16/ex16.1.2.3/main.cpp modified: ../ch16/ex16.12.13/Blob.h modified: ../ch16/ex16.16/main.cpp modified: ../ch16/ex16.16/vec.h modified: ../ch16/ex16.24/Blob.h modified: ../ch16/ex16.24/main.cpp modified: ../ch16/ex16.28/shared_pointer.hpp modified: ../ch16/ex16.28/unique_pointer.h modified: ../ch16/ex16.29/Blob.h modified: ../ch16/ex16.29/shared_pointer.h modified: ../ch16/ex16.29/unique_pointer.h modified: ../ch16/ex16.40/main.cpp modified: ../ch16/ex16.58.59/strvec.h modified: ../ch16/ex16.58.59/vec.h modified: ../ch16/ex16.6/main.cpp modified: ../ch16/ex16.60.61/main.cpp modified: ../ch16/ex16.7.8/main.cpp modified: ../ch17/ex17_10.cpp modified: ../ch17/ex17_11_12_13.cpp modified: ../ch17/ex17_19_20.cpp modified: ../ch17/ex17_21.cpp modified: ../ch17/ex17_23.cpp modified: ../ch17/ex17_33.cpp modified: ../ch17/ex17_4_5_6_7_8.cpp modified: ../ch17/ex17_4_5_6_7_8_SalesData.h modified: ../ch18/ex18.1.2.3.cpp
1 parent cd1940c commit 48aec46

File tree

145 files changed

+296
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+296
-281
lines changed

.tools/format.rb

+18-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,30 @@ def for_commas
2020
end
2121
end
2222
end
23-
23+
24+
def for_curly_brackets
25+
count = 0
26+
each_line do |line|
27+
begin
28+
if line.match /{.*}/
29+
puts (count += 1).to_s; puts line
30+
line.gsub! /{(\S)/, '{ \1'
31+
line.gsub! /(\S)}/, '\1 }'
32+
end
33+
rescue Exception => e
34+
puts e.message + ", ignored."
35+
end
36+
end
37+
end
38+
2439
private
2540
def each_line
2641
@handlers.each do |h|
2742
h.on_each_line { |line| yield line }
28-
end
43+
end
2944
end
3045
end
3146

3247
format = Format.new ARGV[0], [ "cpp", "h", "hpp", "md" ]
3348
format.for_commas
34-
49+
format.for_curly_brackets

ch03/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This code was dereferencing and printing the first item stored in `s`. Since `s`
3939
>Is the following range for legal? If so, what is the type of c?
4040
```cpp
4141
const string s = "Keep out!";
42-
for (auto &c : s){/*... */}
42+
for (auto &c : s){ /*... */ }
4343
```
4444
4545
Depending on the code within for loop body. For example:
@@ -66,10 +66,10 @@ vectors? What are the values of the elements?
6666
vector<int> v1; // size:0, no values.
6767
vector<int> v2(10); // size:10, value:0
6868
vector<int> v3(10, 42); // size:10, value:42
69-
vector<int> v4{10}; // size:1, value:10
70-
vector<int> v5{10, 42}; // size:2, value:10, 42
71-
vector<string> v6{10}; // size:10, value:""
72-
vector<string> v7{10, "hi"}; // size:10, value:"hi"
69+
vector<int> v4{ 10 }; // size:1, value:10
70+
vector<int> v5{ 10, 42 }; // size:2, value:10, 42
71+
vector<string> v6{ 10 }; // size:10, value:""
72+
vector<string> v7{ 10, "hi" }; // size:10, value:"hi"
7373
```
7474
7575
##[Exercise 3.14](ex3_14.cpp)
@@ -161,7 +161,7 @@ p1 += p2 - p1;
161161
##Exercise 3.37
162162
>What does the following program do?
163163
```cpp
164-
const char ca[] = {'h', 'e', 'l', 'l', 'o'};
164+
const char ca[] = { 'h', 'e', 'l', 'l', 'o' };
165165
const char *cp = ca;
166166
while (*cp) {
167167
cout << *cp << endl;

ch04/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ reference: [Usage of the Built-in Comma Operator](http://stackoverflow.com/quest
294294
>Explain the following loop.
295295
```cpp
296296
constexpr int size = 5;
297-
int ia[size] = {1, 2, 3, 4, 5};
297+
int ia[size] = { 1, 2, 3, 4, 5 };
298298
for (int *ptr = ia, ix = 0;
299299
ix != size && ptr != ia+size;
300300
++ix, ++ptr) { /* ... */ }

ch05/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ while (iter != s.end()) { /* . . . */ }
6161
```cpp
6262
//corrrected as:
6363
bool status;
64-
while ((status = find(word))) {/* ... */}
65-
if (!status) {/* ... */}
64+
while ((status = find(word))) { /* ... */ }
65+
if (!status) { /* ... */ }
6666
```
6767

6868
##[Exercise 5.5](ex5_5.cpp)

ch05/ex5_14.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main()
1111
{
1212
if (str == prestr) ++count;
1313
else count = 0;
14-
if (count > max_duplicated.second) max_duplicated = {prestr, count};
14+
if (count > max_duplicated.second) max_duplicated = { prestr, count };
1515
}
1616

1717
if (max_duplicated.first.empty()) cout << "There's no duplicated string." << endl;

ch05/ex5_17.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ using std::cout; using std::endl; using std::vector;
55

66
int main()
77
{
8-
vector<int> vec1{0, 1, 1, 2};
9-
vector<int> vec2{0, 1, 1, 2, 3, 5, 8};
8+
vector<int> vec1{ 0, 1, 1, 2 };
9+
vector<int> vec2{ 0, 1, 1, 2, 3, 5, 8 };
1010

1111
auto size = vec1.size() < vec2.size() ? vec1.size() : vec2.size();
1212
for (decltype(vec1.size()) i = 0; i != size; ++i) {

ch06/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ int divide(int a, int b) { return b != 0 ? a / b : 0; }
410410
411411
## Exercise 6.56
412412
```cpp
413-
std::vector<decltype(func) *> vec{add, subtract, multiply, divide};
413+
std::vector<decltype(func) *> vec{ add, subtract, multiply, divide };
414414
for (auto f : vec)
415415
std::cout << f(2, 2) << std::endl;
416416
```

ch06/ex6_23.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void print(int (&arr)[2])
3535

3636
int main()
3737
{
38-
int i = 0, j[2] = {0, 1};
38+
int i = 0, j[2] = { 0, 1 };
3939
char ch[5] = "pezy";
4040

4141
print(ch);

ch07/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ the condition of the `if` statement would read two Sales_data object at one time
3131
## [Exercise 7.13](ex7_13.cpp)
3232
## Exercise 7.14
3333
```cpp
34-
Sales_data() : units_sold(0) , revenue(0){}
34+
Sales_data() : units_sold(0) , revenue(0){ }
3535
```
3636
3737
## [Exercise 7.15](ex7_15.h)
@@ -122,7 +122,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXX
122122
- less scope for misreading
123123
- can use the member function parameter which name is same as the member name.
124124

125-
void setAddr(const std::string &addr) {this->addr = addr;}
125+
void setAddr(const std::string &addr) { this->addr = addr; }
126126

127127
**Cons**
128128

ch07/ex7_11.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
struct Sales_data {
1515
Sales_data() = default;
16-
Sales_data(const std::string &s):bookNo(s) {}
17-
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
16+
Sales_data(const std::string &s):bookNo(s) { }
17+
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
1818
Sales_data(std::istream &is);
1919

2020
std::string isbn() const { return bookNo; };

ch07/ex7_12.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ std::istream &read(std::istream&, Sales_data&);
1616

1717
struct Sales_data {
1818
Sales_data() = default;
19-
Sales_data(const std::string &s):bookNo(s) {}
20-
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
21-
Sales_data(std::istream &is) { read(is, *this);}
19+
Sales_data(const std::string &s):bookNo(s) { }
20+
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
21+
Sales_data(std::istream &is) { read(is, *this); }
2222

2323
std::string isbn() const { return bookNo; };
2424
Sales_data& combine(const Sales_data&);

ch07/ex7_15.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ std::istream &read(std::istream&, Person&);
1616

1717
struct Person {
1818
Person() = default;
19-
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){}
20-
Person(std::istream &is){read(is, *this);}
19+
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
20+
Person(std::istream &is){ read(is, *this); }
2121

2222
std::string getName() const { return name; }
2323
std::string getAddress() const { return address; }

ch07/ex7_21.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class Sales_data {
1818

1919
public:
2020
Sales_data() = default;
21-
Sales_data(const std::string &s):bookNo(s) {}
22-
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
23-
Sales_data(std::istream &is) { read(is, *this);}
21+
Sales_data(const std::string &s):bookNo(s) { }
22+
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
23+
Sales_data(std::istream &is) { read(is, *this); }
2424

2525
std::string isbn() const { return bookNo; };
2626
Sales_data& combine(const Sales_data&);

ch07/ex7_22.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ struct Person {
1717

1818
public:
1919
Person() = default;
20-
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){}
21-
Person(std::istream &is){read(is, *this);}
20+
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
21+
Person(std::istream &is){ read(is, *this); }
2222

2323
std::string getName() const { return name; }
2424
std::string getAddress() const { return address; }

ch07/ex7_23.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Screen {
1515
using pos = std::string::size_type;
1616

1717
Screen() = default;
18-
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){}
18+
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ }
1919

2020
char get() const { return contents[cursor]; }
2121
char get(pos r, pos c) const { return contents[r*width+c]; }

ch07/ex7_24.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class Screen {
1515
using pos = std::string::size_type;
1616

1717
Screen() = default; // 1
18-
Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){} // 2
19-
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){} // 3
18+
Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){ } // 2
19+
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ } // 3
2020

2121
char get() const { return contents[cursor]; }
2222
char get(pos r, pos c) const { return contents[r*width+c]; }

ch07/ex7_26.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class Sales_data {
2020

2121
public:
2222
Sales_data() = default;
23-
Sales_data(const std::string &s):bookNo(s) {}
24-
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
23+
Sales_data(const std::string &s):bookNo(s) { }
24+
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
2525
Sales_data(std::istream &is) { read(is, *this); }
2626

2727
std::string isbn() const { return bookNo; };

ch07/ex7_27.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Screen {
1616
using pos = std::string::size_type;
1717

1818
Screen() = default; // 1
19-
Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){} // 2
20-
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){} // 3
19+
Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){ } // 2
20+
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ } // 3
2121

2222
char get() const { return contents[cursor]; }
2323
char get(pos r, pos c) const { return contents[r*width+c]; }

ch07/ex7_32.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Screen {
2929
using pos = std::string::size_type;
3030

3131
Screen() = default; // 1
32-
Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){} // 2
33-
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){} // 3
32+
Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){ } // 2
33+
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ } // 3
3434

3535
char get() const { return contents[cursor]; }
3636
char get(pos r, pos c) const { return contents[r*width+c]; }

ch07/ex7_50.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct Person {
1919

2020
public:
2121
Person() = default;
22-
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){}
23-
explicit Person(std::istream &is){read(is, *this);}
22+
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
23+
explicit Person(std::istream &is){ read(is, *this); }
2424

2525
std::string getName() const { return name; }
2626
std::string getAddress() const { return address; }

ch09/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ auto it2 = v2.begin(), it3 = v1.cbegin(), it4 = v2.cbegin();
117117
vector<int> vec; // 0
118118
vector<int> vec(10); // 0
119119
vector<int> vec(10, 1); // 1
120-
vector<int> vec{1, 2, 3, 4, 5}; // 1, 2, 3, 4, 5
120+
vector<int> vec{ 1, 2, 3, 4, 5 }; // 1, 2, 3, 4, 5
121121
vector<int> vec(other_vec); // same as other_vec
122122
vector<int> vec(other_vec.begin(), other_vec.end()); // same as other_vec
123123
```
@@ -127,19 +127,19 @@ vector<int> vec(other_vec.begin(), other_vec.end()); // same as other_vec
127127
128128
- The constructor that takes another container as an argument (excepting array) assumes the container type and element type of both containers are identical. It will also copy all the elements of the received container into the new one:
129129
```cpp
130-
list<int> numbers = {1, 2, 3, 4, 5};
130+
list<int> numbers = { 1, 2, 3, 4, 5 };
131131
list<int> numbers2(numbers); // ok, numbers2 has the same elements as numbers
132132
vector<int> numbers3(numbers); // error: no matching function for call...
133133
list<double> numbers4(numbers); // error: no matching function for call...
134134
```
135135
- The constructor that takes two iterators as arguments does not require the container types to be identical. Moreover, the element types in the new and original containers can differ as long as it is possible to convert the elements we’re copying to the element type of the container we are initializing.
136136
It will also copy only the object delimited by the received iterators.
137137
```cpp
138-
list<int> numbers = {1, 2, 3, 4, 5};
138+
list<int> numbers = { 1, 2, 3, 4, 5 };
139139
list<int> numbers2(numbers.begin(), numbers.end); // ok, numbers2 has the same elements as numbers
140-
vector<int> numbers3(numbers.begin(), --numbers.end()); // ok, numbers3 is {1, 2, 3, 4}
141-
list<double> numbers4(++numbers.beg(), --numbers.end()); // ok, numbers4 is {2, 3, 4}
142-
forward_list<float> numbers5(numbers.begin(), numbers.end()); // ok, number5 is {1, 2, 3, 4, 5}
140+
vector<int> numbers3(numbers.begin(), --numbers.end()); // ok, numbers3 is { 1, 2, 3, 4 }
141+
list<double> numbers4(++numbers.beg(), --numbers.end()); // ok, numbers4 is { 2, 3, 4 }
142+
forward_list<float> numbers5(numbers.begin(), numbers.end()); // ok, number5 is { 1, 2, 3, 4, 5 }
143143
```
144144
145145

ch09/ex9_41.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using std::vector; using std::cout; using std::endl; using std::string;
1414

1515
int main()
1616
{
17-
vector<char> vec{'p', 'e', 'z', 'y'};
17+
vector<char> vec{ 'p', 'e', 'z', 'y' };
1818
string str(vec.begin(), vec.end());
1919

2020
cout << str << endl;

ch09/ex9_47_1.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ using std::string; using std::cout; using std::endl;
1717

1818
int main()
1919
{
20-
string numbers{"123456789"};
21-
string alphabet{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
22-
string str{"ab2c3d7R4E6"};
20+
string numbers{ "123456789" };
21+
string alphabet{ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };
22+
string str{ "ab2c3d7R4E6" };
2323

2424
cout << "numeric characters: ";
2525
for (string::size_type pos = 0; (pos = str.find_first_of(numbers, pos)) != string::npos; ++pos)

ch09/ex9_47_2.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ using std::string; using std::cout; using std::endl;
1717

1818
int main()
1919
{
20-
string numbers{"123456789"};
21-
string alphabet{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
22-
string str{"ab2c3d7R4E6"};
20+
string numbers{ "123456789" };
21+
string alphabet{ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };
22+
string str{ "ab2c3d7R4E6" };
2323

2424
cout << "numeric characters: ";
2525
for (string::size_type pos = 0; (pos = str.find_first_not_of(alphabet, pos)) != string::npos; ++pos)

ch09/ex9_52.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using std::string; using std::cout; using std::endl; using std::stack;
1818

1919
int main()
2020
{
21-
string expression{"This is (pezy)."};
21+
string expression{ "This is (pezy)." };
2222
bool bSeen = false;
2323
stack<char> stk;
2424
for (const auto &s : expression)

ch10/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Cause the library algorithms operate on **iterators**, **not containers**. Thus,
3232
>Write a lambda that takes two ints and returns their sum.
3333
3434
```cpp
35-
auto add = [](int lhs, int rhs){return lhs + rhs;};
35+
auto add = [](int lhs, int rhs){ return lhs + rhs; };
3636
```
3737
3838
## Exercise 10.15:
@@ -41,7 +41,7 @@ The lambda should return the sum of the captured int and the int parameter.
4141
4242
```cpp
4343
int i = 42;
44-
auto add = [i](int num){return i + num;};
44+
auto add = [i](int num){ return i + num; };
4545
```
4646

4747
##[Exercise 10.16](ex10_16.cpp)

ch10/ex10_05.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
//
1212

1313
#include <iostream>
14-
int main(){}
14+
int main(){ }
1515

ch10/ex10_12.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ inline bool compareIsbn(const Sales_data &sd1, const Sales_data &sd2)
1919
int main()
2020
{
2121
Sales_data d1("aa"), d2("aaaa"), d3("aaa"), d4("z"), d5("aaaaz");
22-
std::vector<Sales_data> v{d1, d2, d3, d4, d5};
22+
std::vector<Sales_data> v{ d1, d2, d3, d4, d5 };
2323

2424
// @note the elements the iterators pointing to
2525
// must match the parameters of the predicate.

ch10/ex10_17.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
int main()
1616
{
1717
Sales_data d1("aa"), d2("aaaa"), d3("aaa"), d4("z"), d5("aaaaz");
18-
std::vector<Sales_data> v{d1, d2, d3, d4, d5};
18+
std::vector<Sales_data> v{ d1, d2, d3, d4, d5 };
1919

2020
std::sort(v.begin(), v.end(), [](const Sales_data &sd1, const Sales_data &sd2){
2121
return sd1.isbn().size() < sd2.isbn().size();

ch10/ex10_22.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ bool isBiggerThan6(const string &s, string::size_type sz)
2323

2424
int main()
2525
{
26-
std::vector<string> authors{"Mooophy", "pezy", "Queequeg90", "shbling", "evan617"};
26+
std::vector<string> authors{ "Mooophy", "pezy", "Queequeg90", "shbling", "evan617" };
2727
std::cout << count_if(authors.cbegin(), authors.cend(), bind(isBiggerThan6, _1, 6));
2828
}

0 commit comments

Comments
 (0)