From eea3d25f0cef91b28db5cf00ead30546738e06ef Mon Sep 17 00:00:00 2001 From: Arun Saha Date: Sat, 18 Feb 2017 08:23:28 -0800 Subject: [PATCH] formatting fix --- 03-Style.md | 2 +- 08-Considering_Performance.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/03-Style.md b/03-Style.md index 3b28cef..b2c508f 100644 --- a/03-Style.md +++ b/03-Style.md @@ -332,7 +332,7 @@ They should be preferred to macros, because macros do not honor namespaces, etc. ## Use Operator Overloads Judiciously -Operator overloading was invented to enable expressive syntax. Expressive in the sense that adding two big integers looks like `a + b` and not `a.add(b)`. Another common example is std::string, where it is very common to concatenate two strings with `string1 + string2`. +Operator overloading was invented to enable expressive syntax. Expressive in the sense that adding two big integers looks like `a + b` and not `a.add(b)`. Another common example is `std::string`, where it is very common to concatenate two strings with `string1 + string2`. However, you can easily create unreadable expressions using too much or wrong operator overloading. When overloading operators, there are three basic rules to follow as described [on stackoverflow](http://stackoverflow.com/questions/4421706/operator-overloading/4421708#4421708). diff --git a/08-Considering_Performance.md b/08-Considering_Performance.md index b9c5ddb..bfe53b4 100644 --- a/08-Considering_Performance.md +++ b/08-Considering_Performance.md @@ -179,7 +179,7 @@ if (caseA) { ```cpp // Better Idea -const std::string somevalue = caseA?"Value A":"Value B"; +const std::string somevalue = caseA ? "Value A" : "Value B"; ``` More complex cases can be facilitated with an [immediately-invoked lambda](http://blog2.emptycrate.com/content/complex-object-initialization-optimization-iife-c11).