Skip to content

Commit

Permalink
Sync formatting in chapter03 with the book
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Apr 16, 2017
1 parent 9862bf9 commit 6633593
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Chapter03/03_numeric_cast/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ void test_function1() {
correct_implementation();
} catch (const boost::numeric::positive_overflow& e) {
// Do something specific for positive overflow.
std::cout << "POS OVERFLOW in #" << i << ' ' << e.what() << std::endl;
std::cout << "POS OVERFLOW in #" << i << ' '
<< e.what() << std::endl;
} catch (const boost::numeric::negative_overflow& e) {
// Do something specific for negative overflow.
std::cout <<"NEG OVERFLOW in #" << i << ' ' << e.what() << std::endl;
std::cout <<"NEG OVERFLOW in #" << i << ' '
<< e.what() << std::endl;
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions Chapter03/07_spirit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ date parse_date_time2(const std::string& s) {

date res;

// Use unsigned short as output type, require Radix 10, and from 2 to 2 digits
// Use unsigned short as output type; require Radix 10 and
// from 2 to 2 digits.
uint_parser<unsigned short, 10, 2, 2> u2_;

// Use unsigned short as output type, require Radix 10, and from 4 to 4 digits
// Use unsigned short as output type; require Radix 10 and
// from 4 to 4 digits.
uint_parser<unsigned short, 10, 4, 4> u4_;

const char* first = s.data();
Expand All @@ -72,10 +74,7 @@ date parse_date_time2_cxx(const std::string& s) {

date res;

// Use unsigned short as output type, require Radix 10, and from 2 to 2 digits
uint_parser<unsigned short, 10, 2, 2> u2_;

// Use unsigned short as output type, require Radix 10, and from 4 to 4 digits
uint_parser<unsigned short, 10, 4, 4> u4_;

const auto y = [&res](unsigned short s) { res.year = s; };
Expand All @@ -85,7 +84,7 @@ date parse_date_time2_cxx(const std::string& s) {
const char* first = s.data();
const char* const end = first + s.size();
const bool success = boost::spirit::qi::parse(first, end,
u4_ [y] >> char_('-') >> u2_ [m] >> char_('-') >> u2_ [d]
u4_[y] >> char_('-') >> u2_[m] >> char_('-') >> u2_[d]
);

if (!success || first != end) {
Expand Down

0 comments on commit 6633593

Please sign in to comment.