Skip to content

Commit

Permalink
format {foo} => { foo }
Browse files Browse the repository at this point in the history
	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
  • Loading branch information
Mooophy committed Aug 30, 2015
1 parent cd1940c commit 48aec46
Show file tree
Hide file tree
Showing 145 changed files with 296 additions and 281 deletions.
21 changes: 18 additions & 3 deletions .tools/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,30 @@ def for_commas
end
end
end


def for_curly_brackets
count = 0
each_line do |line|
begin
if line.match /{.*}/
puts (count += 1).to_s; puts line
line.gsub! /{(\S)/, '{ \1'
line.gsub! /(\S)}/, '\1 }'
end
rescue Exception => e
puts e.message + ", ignored."
end
end
end

private
def each_line
@handlers.each do |h|
h.on_each_line { |line| yield line }
end
end
end
end

format = Format.new ARGV[0], [ "cpp", "h", "hpp", "md" ]
format.for_commas

format.for_curly_brackets
12 changes: 6 additions & 6 deletions ch03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This code was dereferencing and printing the first item stored in `s`. Since `s`
>Is the following range for legal? If so, what is the type of c?
```cpp
const string s = "Keep out!";
for (auto &c : s){/*... */}
for (auto &c : s){ /*... */ }
```
Depending on the code within for loop body. For example:
Expand All @@ -66,10 +66,10 @@ vectors? What are the values of the elements?
vector<int> v1; // size:0, no values.
vector<int> v2(10); // size:10, value:0
vector<int> v3(10, 42); // size:10, value:42
vector<int> v4{10}; // size:1, value:10
vector<int> v5{10, 42}; // size:2, value:10, 42
vector<string> v6{10}; // size:10, value:""
vector<string> v7{10, "hi"}; // size:10, value:"hi"
vector<int> v4{ 10 }; // size:1, value:10
vector<int> v5{ 10, 42 }; // size:2, value:10, 42
vector<string> v6{ 10 }; // size:10, value:""
vector<string> v7{ 10, "hi" }; // size:10, value:"hi"
```
##[Exercise 3.14](ex3_14.cpp)
Expand Down Expand Up @@ -161,7 +161,7 @@ p1 += p2 - p1;
##Exercise 3.37
>What does the following program do?
```cpp
const char ca[] = {'h', 'e', 'l', 'l', 'o'};
const char ca[] = { 'h', 'e', 'l', 'l', 'o' };
const char *cp = ca;
while (*cp) {
cout << *cp << endl;
Expand Down
2 changes: 1 addition & 1 deletion ch04/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ reference: [Usage of the Built-in Comma Operator](http://stackoverflow.com/quest
>Explain the following loop.
```cpp
constexpr int size = 5;
int ia[size] = {1, 2, 3, 4, 5};
int ia[size] = { 1, 2, 3, 4, 5 };
for (int *ptr = ia, ix = 0;
ix != size && ptr != ia+size;
++ix, ++ptr) { /* ... */ }
Expand Down
4 changes: 2 additions & 2 deletions ch05/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ while (iter != s.end()) { /* . . . */ }
```cpp
//corrrected as:
bool status;
while ((status = find(word))) {/* ... */}
if (!status) {/* ... */}
while ((status = find(word))) { /* ... */ }
if (!status) { /* ... */ }
```

##[Exercise 5.5](ex5_5.cpp)
Expand Down
2 changes: 1 addition & 1 deletion ch05/ex5_14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main()
{
if (str == prestr) ++count;
else count = 0;
if (count > max_duplicated.second) max_duplicated = {prestr, count};
if (count > max_duplicated.second) max_duplicated = { prestr, count };
}

if (max_duplicated.first.empty()) cout << "There's no duplicated string." << endl;
Expand Down
4 changes: 2 additions & 2 deletions ch05/ex5_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ using std::cout; using std::endl; using std::vector;

int main()
{
vector<int> vec1{0, 1, 1, 2};
vector<int> vec2{0, 1, 1, 2, 3, 5, 8};
vector<int> vec1{ 0, 1, 1, 2 };
vector<int> vec2{ 0, 1, 1, 2, 3, 5, 8 };

auto size = vec1.size() < vec2.size() ? vec1.size() : vec2.size();
for (decltype(vec1.size()) i = 0; i != size; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion ch06/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ int divide(int a, int b) { return b != 0 ? a / b : 0; }
## Exercise 6.56
```cpp
std::vector<decltype(func) *> vec{add, subtract, multiply, divide};
std::vector<decltype(func) *> vec{ add, subtract, multiply, divide };
for (auto f : vec)
std::cout << f(2, 2) << std::endl;
```
Expand Down
2 changes: 1 addition & 1 deletion ch06/ex6_23.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void print(int (&arr)[2])

int main()
{
int i = 0, j[2] = {0, 1};
int i = 0, j[2] = { 0, 1 };
char ch[5] = "pezy";

print(ch);
Expand Down
4 changes: 2 additions & 2 deletions ch07/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ the condition of the `if` statement would read two Sales_data object at one time
## [Exercise 7.13](ex7_13.cpp)
## Exercise 7.14
```cpp
Sales_data() : units_sold(0) , revenue(0){}
Sales_data() : units_sold(0) , revenue(0){ }
```
## [Exercise 7.15](ex7_15.h)
Expand Down Expand Up @@ -122,7 +122,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXX
- less scope for misreading
- can use the member function parameter which name is same as the member name.

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

**Cons**

Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_11.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

struct Sales_data {
Sales_data() = default;
Sales_data(const std::string &s):bookNo(s) {}
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
Sales_data(const std::string &s):bookNo(s) { }
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
Sales_data(std::istream &is);

std::string isbn() const { return bookNo; };
Expand Down
6 changes: 3 additions & 3 deletions ch07/ex7_12.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ std::istream &read(std::istream&, Sales_data&);

struct Sales_data {
Sales_data() = default;
Sales_data(const std::string &s):bookNo(s) {}
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
Sales_data(std::istream &is) { read(is, *this);}
Sales_data(const std::string &s):bookNo(s) { }
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
Sales_data(std::istream &is) { read(is, *this); }

std::string isbn() const { return bookNo; };
Sales_data& combine(const Sales_data&);
Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_15.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ std::istream &read(std::istream&, Person&);

struct Person {
Person() = default;
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){}
Person(std::istream &is){read(is, *this);}
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
Person(std::istream &is){ read(is, *this); }

std::string getName() const { return name; }
std::string getAddress() const { return address; }
Expand Down
6 changes: 3 additions & 3 deletions ch07/ex7_21.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class Sales_data {

public:
Sales_data() = default;
Sales_data(const std::string &s):bookNo(s) {}
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
Sales_data(std::istream &is) { read(is, *this);}
Sales_data(const std::string &s):bookNo(s) { }
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
Sales_data(std::istream &is) { read(is, *this); }

std::string isbn() const { return bookNo; };
Sales_data& combine(const Sales_data&);
Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_22.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ struct Person {

public:
Person() = default;
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){}
Person(std::istream &is){read(is, *this);}
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
Person(std::istream &is){ read(is, *this); }

std::string getName() const { return name; }
std::string getAddress() const { return address; }
Expand Down
2 changes: 1 addition & 1 deletion ch07/ex7_23.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Screen {
using pos = std::string::size_type;

Screen() = default;
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){}
Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ }

char get() const { return contents[cursor]; }
char get(pos r, pos c) const { return contents[r*width+c]; }
Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_24.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Screen {
using pos = std::string::size_type;

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

char get() const { return contents[cursor]; }
char get(pos r, pos c) const { return contents[r*width+c]; }
Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_26.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Sales_data {

public:
Sales_data() = default;
Sales_data(const std::string &s):bookNo(s) {}
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){}
Sales_data(const std::string &s):bookNo(s) { }
Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
Sales_data(std::istream &is) { read(is, *this); }

std::string isbn() const { return bookNo; };
Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_27.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class Screen {
using pos = std::string::size_type;

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

char get() const { return contents[cursor]; }
char get(pos r, pos c) const { return contents[r*width+c]; }
Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Screen {
using pos = std::string::size_type;

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

char get() const { return contents[cursor]; }
char get(pos r, pos c) const { return contents[r*width+c]; }
Expand Down
4 changes: 2 additions & 2 deletions ch07/ex7_50.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ struct Person {

public:
Person() = default;
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){}
explicit Person(std::istream &is){read(is, *this);}
Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
explicit Person(std::istream &is){ read(is, *this); }

std::string getName() const { return name; }
std::string getAddress() const { return address; }
Expand Down
12 changes: 6 additions & 6 deletions ch09/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ auto it2 = v2.begin(), it3 = v1.cbegin(), it4 = v2.cbegin();
vector<int> vec; // 0
vector<int> vec(10); // 0
vector<int> vec(10, 1); // 1
vector<int> vec{1, 2, 3, 4, 5}; // 1, 2, 3, 4, 5
vector<int> vec{ 1, 2, 3, 4, 5 }; // 1, 2, 3, 4, 5
vector<int> vec(other_vec); // same as other_vec
vector<int> vec(other_vec.begin(), other_vec.end()); // same as other_vec
```
Expand All @@ -127,19 +127,19 @@ vector<int> vec(other_vec.begin(), other_vec.end()); // same as other_vec
- 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:
```cpp
list<int> numbers = {1, 2, 3, 4, 5};
list<int> numbers = { 1, 2, 3, 4, 5 };
list<int> numbers2(numbers); // ok, numbers2 has the same elements as numbers
vector<int> numbers3(numbers); // error: no matching function for call...
list<double> numbers4(numbers); // error: no matching function for call...
```
- 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.
It will also copy only the object delimited by the received iterators.
```cpp
list<int> numbers = {1, 2, 3, 4, 5};
list<int> numbers = { 1, 2, 3, 4, 5 };
list<int> numbers2(numbers.begin(), numbers.end); // ok, numbers2 has the same elements as numbers
vector<int> numbers3(numbers.begin(), --numbers.end()); // ok, numbers3 is {1, 2, 3, 4}
list<double> numbers4(++numbers.beg(), --numbers.end()); // ok, numbers4 is {2, 3, 4}
forward_list<float> numbers5(numbers.begin(), numbers.end()); // ok, number5 is {1, 2, 3, 4, 5}
vector<int> numbers3(numbers.begin(), --numbers.end()); // ok, numbers3 is { 1, 2, 3, 4 }
list<double> numbers4(++numbers.beg(), --numbers.end()); // ok, numbers4 is { 2, 3, 4 }
forward_list<float> numbers5(numbers.begin(), numbers.end()); // ok, number5 is { 1, 2, 3, 4, 5 }
```
Expand Down
2 changes: 1 addition & 1 deletion ch09/ex9_41.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using std::vector; using std::cout; using std::endl; using std::string;

int main()
{
vector<char> vec{'p', 'e', 'z', 'y'};
vector<char> vec{ 'p', 'e', 'z', 'y' };
string str(vec.begin(), vec.end());

cout << str << endl;
Expand Down
6 changes: 3 additions & 3 deletions ch09/ex9_47_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ using std::string; using std::cout; using std::endl;

int main()
{
string numbers{"123456789"};
string alphabet{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string str{"ab2c3d7R4E6"};
string numbers{ "123456789" };
string alphabet{ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };
string str{ "ab2c3d7R4E6" };

cout << "numeric characters: ";
for (string::size_type pos = 0; (pos = str.find_first_of(numbers, pos)) != string::npos; ++pos)
Expand Down
6 changes: 3 additions & 3 deletions ch09/ex9_47_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ using std::string; using std::cout; using std::endl;

int main()
{
string numbers{"123456789"};
string alphabet{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string str{"ab2c3d7R4E6"};
string numbers{ "123456789" };
string alphabet{ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };
string str{ "ab2c3d7R4E6" };

cout << "numeric characters: ";
for (string::size_type pos = 0; (pos = str.find_first_not_of(alphabet, pos)) != string::npos; ++pos)
Expand Down
2 changes: 1 addition & 1 deletion ch09/ex9_52.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using std::string; using std::cout; using std::endl; using std::stack;

int main()
{
string expression{"This is (pezy)."};
string expression{ "This is (pezy)." };
bool bSeen = false;
stack<char> stk;
for (const auto &s : expression)
Expand Down
4 changes: 2 additions & 2 deletions ch10/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Cause the library algorithms operate on **iterators**, **not containers**. Thus,
>Write a lambda that takes two ints and returns their sum.
```cpp
auto add = [](int lhs, int rhs){return lhs + rhs;};
auto add = [](int lhs, int rhs){ return lhs + rhs; };
```
## Exercise 10.15:
Expand All @@ -41,7 +41,7 @@ The lambda should return the sum of the captured int and the int parameter.
```cpp
int i = 42;
auto add = [i](int num){return i + num;};
auto add = [i](int num){ return i + num; };
```

##[Exercise 10.16](ex10_16.cpp)
Expand Down
2 changes: 1 addition & 1 deletion ch10/ex10_05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
//

#include <iostream>
int main(){}
int main(){ }

2 changes: 1 addition & 1 deletion ch10/ex10_12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ inline bool compareIsbn(const Sales_data &sd1, const Sales_data &sd2)
int main()
{
Sales_data d1("aa"), d2("aaaa"), d3("aaa"), d4("z"), d5("aaaaz");
std::vector<Sales_data> v{d1, d2, d3, d4, d5};
std::vector<Sales_data> v{ d1, d2, d3, d4, d5 };

// @note the elements the iterators pointing to
// must match the parameters of the predicate.
Expand Down
2 changes: 1 addition & 1 deletion ch10/ex10_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
int main()
{
Sales_data d1("aa"), d2("aaaa"), d3("aaa"), d4("z"), d5("aaaaz");
std::vector<Sales_data> v{d1, d2, d3, d4, d5};
std::vector<Sales_data> v{ d1, d2, d3, d4, d5 };

std::sort(v.begin(), v.end(), [](const Sales_data &sd1, const Sales_data &sd2){
return sd1.isbn().size() < sd2.isbn().size();
Expand Down
2 changes: 1 addition & 1 deletion ch10/ex10_22.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ bool isBiggerThan6(const string &s, string::size_type sz)

int main()
{
std::vector<string> authors{"Mooophy", "pezy", "Queequeg90", "shbling", "evan617"};
std::vector<string> authors{ "Mooophy", "pezy", "Queequeg90", "shbling", "evan617" };
std::cout << count_if(authors.cbegin(), authors.cend(), bind(isBiggerThan6, _1, 6));
}
Loading

0 comments on commit 48aec46

Please sign in to comment.