minor style fixes

This commit is contained in:
Thibault Kruse 2015-10-13 12:33:26 +02:00
parent 6d9db03404
commit 5d1d990cd9

View File

@ -5959,7 +5959,7 @@ To find function objects and functions defined in a separate namespace to "custo
##### Example
Consider `swap`. It is a general (standard library) function with a definintion that will work for just about any type.
Consider `swap`. It is a general (standard library) function with a definition that will work for just about any type.
However, it is desirable to define specific `swap()`s for specific types.
For example, the general `swap()` will copy the elements of two `vector`s being swapped, whereas a good specific implementation will not copy elements at all.
@ -5971,7 +5971,7 @@ For example, the general `swap()` will copy the elements of two `vector`s being
void f1(N::X& a, N::X& b)
{
std::swap(a,b); // propably not what we wanted: calls std::swap()
std::swap(a, b); // probably not what we wanted: calls std::swap()
}
The `std::swap()` in `f1()` does exactly what we asked it to do: it calls the `swap()` in namespace `std`.
@ -5993,7 +5993,6 @@ This is done by including the general function in the lookup for the function:
swap(a,b); // calls N::swap if it exists, otherwise std::swap
}
##### Enforcement
Unlikely, except for known customization points, such as `swap`.
@ -6102,7 +6101,7 @@ Macros do not obey scope and type rules.
##### Example
First some bad old code
First some bad old code:
// webcolors.h (third party header)
#define RED 0xFF0000
@ -7114,7 +7113,7 @@ Statement rules:
* [ES.75: Avoid `do`-statements](#Res-do)
* [ES.76: Avoid `goto`](#Res-goto)
* [ES.77: ??? `continue`](#Res-continue)
* [ES.78: Always end non-empty a `case` with a `break`](#Res-break)
* [ES.78: Always end a non-empty `case` with a `break`](#Res-break)
* [ES.79: ??? `default`](#Res-default)
* [ES.85: Make empty statements visible](#Res-empty)
@ -7544,7 +7543,7 @@ This cannot trivially be rewritten to initialize `i` and `j` with initializers.
Note that for types with a default constructor, attempting to postpone initialization simply leads to a default initialization followed by an assignment.
A popular reason for such examples is "efficiency", but a compiler that can detect whether we made a used-before-set error can also eliminate any redundant double initialization.
At the cost of repeating `cond` we could write
At the cost of repeating `cond` we could write:
widget i = (cond) ? f1() : f3();
widget j = (cond) ? f2() : f4();
@ -7617,7 +7616,7 @@ In the not uncommon case where the input target and the input operation get sepa
A good optimizer should know about input operations and eliminate the redundant operation.
##### Example:
##### Example
Using an `unitialized` value is a symptom of a problem and not a solution:
@ -7641,7 +7640,7 @@ Now the compiler cannot even simply detect a used-befor-set.
##### Note
Sometimes, a lambda can be used as an initializer to avoid an uninitialized variable.
Sometimes, a lambda can be used as an initializer to avoid an uninitialized variable:
error_code ec;
Value v = [&] {
@ -8259,7 +8258,7 @@ This is an ad-hoc simulation of destructors. Declare your resources with handles
???
### <a name="Res-break"></a> ES.78: Always end non-empty a `case` with a `break`
### <a name="Res-break"></a> ES.78: Always end a non-empty `case` with a `break`
##### Reason
@ -13059,12 +13058,12 @@ It's verbose and only needed where C compatibility matters.
###### Note
Even Dennis Ritchie deemed `void f(void)` an abomination.
You can make an argument for that abomination in C when function prototypes were rare so that banning
You can make an argument for that abomination in C when function prototypes were rare so that banning:
int f();
f(1, 2, "weird but valid C89"); // hope that f() is defined int f(a, b, c) char* c; { /* ... */ }
would have cause major problems, but not in the 21st century and in C++.
would have caused major problems, but not in the 21st century and in C++.
# <a name="S-faq"></a> FAQ: Answers to frequently asked questions
@ -13734,10 +13733,10 @@ When is a class a container? ???
# <a name="S-glossary"></a> Glossary
A relatively informal definition of twrms used in the guidelines
A relatively informal definition of terms used in the guidelines
(based of the glossary in [Programming: Principles and Practice using C++](http://www.stroustrup.com/programming.html))
* *abstract*: classa class that cannot be directly used to create objects; often used to define an interface to derived classes.
* *abstract class*:a class that cannot be directly used to create objects; often used to define an interface to derived classes.
A class is made abstract by having a pure virtual function or a protected constructor.
* *abstraction*:a description of something that selectively and deliberately ignores (hides) details (e.g., implementation details); selective ignorance.
* *address*:a value that allows us to find an object in a computers memory.