From c609d23b01b01b9edac1796e111c70f8aaa695fa Mon Sep 17 00:00:00 2001 From: tink Date: Sun, 26 May 2024 10:35:32 +0800 Subject: [PATCH] update --- content/en/docs/A First Impression.md | 2 +- content/en/docs/IOStreams.md | 8 +-- public/docs/A-First-Impression/index.html | 60 +++++++++++------------ public/docs/IOStreams/index.html | 46 ++++++++--------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/content/en/docs/A First Impression.md b/content/en/docs/A First Impression.md index 063f730..1d4a9cb 100644 --- a/content/en/docs/A First Impression.md +++ b/content/en/docs/A First Impression.md @@ -112,7 +112,7 @@ Marshall Cline's advice can be improved, though. Here's a recipe that will effor Let's apply this recipe to the following (by itself irrelevant) complex declaration. Little arrows indicate how far we should read at each step and the direction of the arrow indicates the reading direction: -``` +```bash char const *(* const (*(*ip)())[])[] ip Start at the variable's name: diff --git a/content/en/docs/IOStreams.md b/content/en/docs/IOStreams.md index 22afd69..2008795 100644 --- a/content/en/docs/IOStreams.md +++ b/content/en/docs/IOStreams.md @@ -148,11 +148,11 @@ Conditions are represented by the following condition flags: Several condition member functions are available to manipulate or determine the states of `ios` objects. Originally they returned `int` values, but their current return type is `bool`: -- bool ios::bad(): +- **bool ios::bad()**: - the value true is returned when the stream's badbit has been set and false otherwise. If true is returned it indicates that an illegal operation has been requested at the level of the streambuf object to which the stream interfaces. What does this mean? It indicates that the streambuf itself is behaving unexpectedly. Consider the following example: + the value true is returned when the stream's `badbit` has been set and false otherwise. If true is returned it indicates that an illegal operation has been requested at the level of the streambuf object to which the stream interfaces. What does this mean? It indicates that the streambuf itself is behaving unexpectedly. Consider the following example: ```cpp - std::ostream error(0); + std::ostream error(0); ``` Here an `ostream` object is constructed without providing it with a working `streambuf` object. Since this `streambuf` will never operate properly, its `badbit` flag is raised from the very beginning: `error.bad()` returns true. @@ -1648,7 +1648,7 @@ In this example Like `fstream` objects string-stream objects can also be used for reading and writing. After including the `` header file a `std::stringstream` can be defined which supports both reading and writing. After inserting information into a `stringstream` object `seekg(0)` can be called to read its info from the beginning of its content. When a `stringstream` must repeatedly be used for reading and writing call its `clear` and `str` members before starting a new writing cycle. Alternatively, a `stringstream` str can be reinitialized using `str = stringstream{}`. Here is an example: -``` +```cpp #include #include using namespace std; diff --git a/public/docs/A-First-Impression/index.html b/public/docs/A-First-Impression/index.html index 2498bd5..f0b3e0c 100644 --- a/public/docs/A-First-Impression/index.html +++ b/public/docs/A-First-Impression/index.html @@ -256,36 +256,36 @@ https://github.com/alex-shpak/hugo-book
  • If you reached an opening parenthesis, continue at step 2 beyond the parenthesis where you previously stopped.
  • Let’s apply this recipe to the following (by itself irrelevant) complex declaration. Little arrows indicate how far we should read at each step and the direction of the arrow indicates the reading direction:

    -
    char const *(* const (*(*ip)())[])[]
    -
    -                            ip          Start at the variable's name:
    -                                            'ip' is
    -
    -                            ip)         Hitting a closing paren: revert
    -                            -->
    -
    -                        (*ip)         Find the matching open paren:
    -                        <-                'a pointer to'
    -
    -                        (*ip)())      The next unmatched closing par:
    -                            -->          'a function (not expecting
    -                                            arguments)'
    -
    -                        (*(*ip)())      Find the matching open paren:
    -                        <-                  'returning a pointer to'
    -
    -                        (*(*ip)())[])   The next closing par:
    -                                -->       'an array of'
    -
    -            (* const (*(*ip)())[])   Find the matching open paren:
    -            <--------                    'const pointers to'
    -
    -            (* const (*(*ip)())[])[] Read until the end:
    -                                    ->     'an array of'
    -
    -char const *(* const (*(*ip)())[])[] Read backwards what's left:
    -<-----------                             'pointers to const chars'
    -

    Collecting all the parts, we get for char const *(* const (*(*ip)())[])[]: ip is a pointer to a function (not expecting arguments), returning a pointer to an array of const pointers to an array of pointers to const chars. This is what ip represents; the recipe can be used to parse any declaration you ever encounter.

    +
    char const *(* const (*(*ip)())[])[]
    +
    +                            ip          Start at the variable's name:
    +                                            'ip' is
    +
    +                            ip)         Hitting a closing paren: revert
    +                            -->
    +
    +                        (*ip)         Find the matching open paren:
    +                        <-                'a pointer to'
    +
    +                        (*ip)())      The next unmatched closing par:
    +                            -->          'a function (not expecting
    +                                            arguments)'
    +
    +                        (*(*ip)())      Find the matching open paren:
    +                        <-                  'returning a pointer to'
    +
    +                        (*(*ip)())[])   The next closing par:
    +                                -->       'an array of'
    +
    +            (* const (*(*ip)())[])   Find the matching open paren:
    +            <--------                    'const pointers to'
    +
    +            (* const (*(*ip)())[])[] Read until the end:
    +                                    ->     'an array of'
    +
    +char const *(* const (*(*ip)())[])[] Read backwards what's left:
    +<-----------                             'pointers to const chars'
    +

    Collecting all the parts, we get for char const *(* const (*(*ip)())[])[]: ip is a pointer to a function (not expecting arguments), returning a pointer to an array of const pointers to an array of pointers to const chars. This is what ip represents; the recipe can be used to parse any declaration you ever encounter.

    3.1.2: Namespaces # diff --git a/public/docs/IOStreams/index.html b/public/docs/IOStreams/index.html index 0caf5cb..bf873f2 100644 --- a/public/docs/IOStreams/index.html +++ b/public/docs/IOStreams/index.html @@ -352,9 +352,9 @@ https://github.com/alex-shpak/hugo-book

    Several condition member functions are available to manipulate or determine the states of ios objects. Originally they returned int values, but their current return type is bool:

    • -

      bool ios::bad():

      -

      the value true is returned when the stream’s badbit has been set and false otherwise. If true is returned it indicates that an illegal operation has been requested at the level of the streambuf object to which the stream interfaces. What does this mean? It indicates that the streambuf itself is behaving unexpectedly. Consider the following example:

      -
          std::ostream error(0);
      +

      bool ios::bad():

      +

      the value true is returned when the stream’s badbit has been set and false otherwise. If true is returned it indicates that an illegal operation has been requested at the level of the streambuf object to which the stream interfaces. What does this mean? It indicates that the streambuf itself is behaving unexpectedly. Consider the following example:

      +
      std::ostream error(0);
       

      Here an ostream object is constructed without providing it with a working streambuf object. Since this streambuf will never operate properly, its badbit flag is raised from the very beginning: error.bad() returns true.

    • @@ -1757,26 +1757,26 @@ the current object is reinitialized with new initial content.

    Like fstream objects string-stream objects can also be used for reading and writing. After including the <sstream> header file a std::stringstream can be defined which supports both reading and writing. After inserting information into a stringstream object seekg(0) can be called to read its info from the beginning of its content. When a stringstream must repeatedly be used for reading and writing call its clear and str members before starting a new writing cycle. Alternatively, a stringstream str can be reinitialized using str = stringstream{}. Here is an example:

    -
    #include <iostream>
    -#include <sstream>
    -using namespace std;
    -
    -int main(int argc, char **argv)
    -{
    -    stringstream io;
    -    for (size_t redo = 0; redo != 2; ++redo)
    -    {
    -        io.clear();                 // clears the not-good flags
    -        io.str("");
    -        io << argv[0] << '\n';
    -
    -        io.seekg(0);
    -        string line;
    -        while (getline(io, line))   // results in io.eof()
    -            cout << line << '\n';
    -    }
    -}
    -
    +
    #include <iostream>
    +#include <sstream>
    +using namespace std;
    +
    +int main(int argc, char **argv)
    +{
    +    stringstream io;
    +    for (size_t redo = 0; redo != 2; ++redo)
    +    {
    +        io.clear();                 // clears the not-good flags
    +        io.str("");
    +        io << argv[0] << '\n';
    +
    +        io.seekg(0);
    +        string line;
    +        while (getline(io, line))   // results in io.eof()
    +            cout << line << '\n';
    +    }
    +}
    +