From 309f1f3731f774827c64f55cf4404a1685edecee Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Wed, 11 Aug 2021 12:41:16 +0200 Subject: [PATCH] book: wrap code Fixes #186 --- book/en-us/02-usability.md | 7 +++++-- book/zh-cn/02-usability.md | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/book/en-us/02-usability.md b/book/en-us/02-usability.md index 935fce6..f289239 100644 --- a/book/en-us/02-usability.md +++ b/book/en-us/02-usability.md @@ -312,7 +312,8 @@ be used as a formal parameter of a normal function, for example: ```Cpp public: void foo(std::initializer_list list) { - for (std::initializer_list::iterator it = list.begin(); it != list.end(); ++it) vec.push_back(*it); + for (std::initializer_list::iterator it = list.begin(); + it != list.end(); ++it) vec.push_back(*it); } magicFoo.foo({6,7,8,9}); @@ -1046,7 +1047,9 @@ And we want to get the value of the enumeration value, we will have to explicitl ```cpp #include template -std::ostream& operator<<(typename std::enable_if::value, std::ostream>::type& stream, const T& e) +std::ostream& operator<<( + typename std::enable_if::value, + std::ostream>::type& stream, const T& e) { return stream << static_cast::type>(e); } diff --git a/book/zh-cn/02-usability.md b/book/zh-cn/02-usability.md index 489eea5..18f2d53 100644 --- a/book/zh-cn/02-usability.md +++ b/book/zh-cn/02-usability.md @@ -258,7 +258,8 @@ int main() { ```Cpp public: void foo(std::initializer_list list) { - for (std::initializer_list::iterator it = list.begin(); it != list.end(); ++it) vec.push_back(*it); + for (std::initializer_list::iterator it = list.begin(); + it != list.end(); ++it) vec.push_back(*it); } magicFoo.foo({6,7,8,9}); @@ -964,7 +965,9 @@ if (new_enum::value3 == new_enum::value4) { ```cpp #include template -std::ostream& operator<<(typename std::enable_if::value, std::ostream>::type& stream, const T& e) +std::ostream& operator<<( + typename std::enable_if::value, + std::ostream>::type& stream, const T& e) { return stream << static_cast::type>(e); }