C++ Core Guidelines: Improved Performance with Iostreams
As easy as my title and the rules of the C++ core guidelines sound, getting more performance out of the iostreams is no no-brainer.
This author has not written his bio yet.
But we are proud to say that Rainer Grimm contributed 702 entries already.
As easy as my title and the rules of the C++ core guidelines sound, getting more performance out of the iostreams is no no-brainer.
Today’s post is about what you should know about Iostreams. In particular, I write about formatted and unformatted In- and Output.
When you interact with the outside world, the iostream library is the way to go in C++. As always, you have to keep a few rules in mind. Let me show which rules.
The C++ core guidelines use the term string as a sequence of characters. Consequently, the guidelines are about C-strings, C++-strings, the C++17 std::string_view‘s, and std::byte‘s.
When you access an element outside a container of the STL, the result is not so promising. Your effect may be an error or undefined behavior. Undefined behavior means all bets are open.
Modern C++ has eight associative containers, but your special friends should be std::map and std::unordered_map. Why? Let me explain it in this post.
In 99 % of your use cases for a sequential container, you are outstanding with a std::array or a std::vector. What? If you don’t believe me, read this post.
The rules to the C++ standard library are mainly about containers, strings, and iostreams.
My last post gave you an introduction to modules in C++20. This post shows how to use existing modules.
Modules are one of the five prominent features of C++20. Modules will overcome the restrictions of header files. They promise a lot. For example, the separation of header and source files becomes as obsolete as the preprocessor. Ultimately, we will also have faster build times and an easier way to build packages.
