diff --git a/01-string-and-character-literals.md b/01-string-and-character-literals.md index e090cea..904de69 100644 --- a/01-string-and-character-literals.md +++ b/01-string-and-character-literals.md @@ -133,7 +133,7 @@ While little hands make vain pretence Our wanderings to guide. ``` -* Now use a (non-raw) string literal for each line and a single call to `print()` with suitable escape characters. What happens if you remove all of the stream insertion operators *except* for the first? (Explanation: *concatenation* of adjacent string literals is automatically performed by the pre-processor.) +* Now use a (non-raw) string literal for each line and a single call to `print()` with suitable escape characters. You concatenate the string literals without any operator: *concatenation* of adjacent string literals is automatically performed by the pre-processor. * Modify `01-title.cpp` to output the title of your favorite book or film centered on the console window (assume an 80 character fixed width, and change the size of the console window if different). @@ -156,7 +156,7 @@ The following table lists C++ types, sizes, target encodings, literals and objec | char32_t | 32 | UTF-32 | U"abcd" | U'a' | UR"(abcd)" | u32string | n/a | no | | wchar_t | 16/32 | n/a + | L"abcd" | L'a' | LR"(abcd)" | wstring | wcout/wcerr | no | -* An explicit cast to type `char` in `operator<<` may be required when using `cout`/`cerr`, for example: `cout << static_cast(u8"Hello \u20AC!\n");`. +* An explicit cast to type `char` in `operator<<` may be required when using `cout`/`cerr`, for example: `cout << reinterpret_cast(u8"Hello \u20AC!\n");`. + The `wchar_t` encoding and streams under Windows are 16-bit and support UTF-16. diff --git a/02-variables-scopes-and-namespaces.md b/02-variables-scopes-and-namespaces.md index 90f799d..732db2b 100644 --- a/02-variables-scopes-and-namespaces.md +++ b/02-variables-scopes-and-namespaces.md @@ -468,6 +468,9 @@ In fact, `constexpr` expressions can be complex with recent compilers, as long a #include using namespace std; +// Note: currently, not all compilers mark `acos` as a +// constexpr function in cmath. The following line might +// not compile with `clang++` for example. constexpr double PI1 = acos(-1.0); constexpr double PI2 = 22.0 / 7.0; @@ -480,7 +483,7 @@ int main() { } ``` -(Hint: this program is the first to require an additional header to ``; you may need to add `-lm` to the compile command under Linux/MacOS in order to link in the math library containing the `acos()` function.) +(Hint: this program is the first to require an additional header to ``; you may need to add `-lm` to the compile command under Linux in order to link in the math library containing the `acos()` function.) **Experiment** diff --git a/04-functions.md b/04-functions.md index 3d0a927..fad23eb 100644 --- a/04-functions.md +++ b/04-functions.md @@ -538,7 +538,7 @@ The keyword `noexcept` is used to declare that a function is guaranteed to not t #include using namespace std; -void throw_if_zero(int i) { +void throw_if_zero(int i) noexcept { if (!i) { throw runtime_error("found a zero"); }