In the first part of the series we looked at lambdas from the perspective of C++03, C++11 and C++14. In that article, I described the motivation behind this powerful C++ feature, basic usage, syntax and improvements in each of the language standards. I also mentioned several corner cases.
Now it’s time to move into C++17 and look a bit into the future (very near future!
I released “C++17 In Detail” in August 2018, and I set the status to 90%. I didn’t expect that writing of that remaining 10% would take me so long :) Now it’s high time to set the counter to 100%.
That’s why I’m pleased to announce that my book “C++17 In Detail” is now done!
While I was doing research for my book and blog posts about C++17 several times I stumbled upon this pattern for visitation of std::variant:
template<class... Ts> struct overload : Ts... { using Ts::operator()...; }; template<class... Ts> overload(Ts...) -> overload<Ts...>; std::variant<int, float> intFloat { 0.0f }; std::visit(overload( [](const int& i) { .
On Friday 18th January I’ve pushed another update for the book. This time I rewrote the whole chapter about std::filesystem. Please have a look at what changed and what are the plans.
The book got more than 25 new pages!
std::filesystem - Chapter Rewrite The book had a filesystem chapter from the start, but it was concise and didn’t contain much information.
Subtitle: Learning std::filesystem through file_size routines.
Last week I wrote a short post that explained how to use std::filesystem::file_size. Today I’d like to continue and show some significant differences that this new functionality has over the “older” techniques (like reading a file and getting its file position).
We’ll also learn something about permissions and how to manage them in std::filesystem.
Before C++17 we could often complain that even simple tasks as getting a file size were complicated. With std::filesystem things get a bit easier!
Get a File Size STL before C++17 didn’t contain any direct facilities to work with a filesystem. We could only use third party libraries (like Boost), or system APIs.
Learning new language and library features in isolation might not be the best choice. That’s why in my book I also added bigger examples where many C++ elements coexist together.
This time I’d like to describe another book update where I create and walk through a CSV reader application. The application uses a lot of language and library components.
With C++17 we get another facility to handle the conversion between text and numbers. Why should we care about the new routines? Are they better in any way?
Intro C++, before C++17, offered several options when it comes to string conversion:
sprintf / snprintf sscanf atol strtol strstream stringstream to_string stoi and similar functions And with C++17 you get another option: std::from_chars!
C++17 brings us parallel algorithms. However, there are not many implementations where you can use the new features. The situation is getting better and better, as we have the MSVC implementation and now Intel’s version will soon be available as the base for libstdc++ for GCC. Since the library is important, I’ve decided to see how to use it and what it offers.
Yesterday I finally updated the book! The main point of this refresh was to provide an updated and rewritten version of the “Parallel Algorithms” chapter. “C++17 In Detail” grew by 20 pages (up to 270).
See what’s inside.
The Changes The release notes are straightforward this time :)
Parallel Algorithms chapter updated Some smaller fixes (for example I updated the link to code samples: Source Code (ZIP) Here’s the link to the book:
In September our local C++ User Group started a “new year” of meetings after a little break in August. I had a pleasure to give a talk about string operations in C++17.
Here are the slides and additional comments.
The Talk For my book I wrote a lot of content about string_view, std::searcher and std::to_chars, std::from_chars and I wanted to make a short summary of those features.
I’m happy to announce that last Friday I updated the book! “C++17 In Detail” grew by 31 pages (up to 250), includes two new chapters and lots of “bug” fixes and better explanations.
See what’s inside.
The Changes Here’s the short version of the release notes:
– New chapter - String Conversions