All posts in "STL"

Is Unzip a Special Case of Transform?

Published February 26, 2019 - 0 Comments

In the Smart Output Iterators library, the unzip output iterator allows to send the various elements contained in tuples or pairs to as many output collections: std::vector<std::tuple<int, int, int>> lines = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12} }; std::vector<int> column1, column2, column3; std::copy(begin(lines), end(lines), fluent::output::unzip(back_inserter(column1), back_inserter(column2), back_inserter(column3))); This […]

Applying Several Transforms in One Pass on a Collection

Published February 22, 2019 - 0 Comments

Applying a function to each element of a collection and outputting the results into another collection is a very common thing to do, in C++ or elsewhere. In C++, we have the std::transform algorithm to do this, a central piece of the STL algorithms library. To illustrate, consider the following program: #include <algorithm> #include <iterator> […]

How Smart Output Iterators Avoid the TPOIASI

Published February 15, 2019 - 0 Comments
smart output iterators range C++

In the last post we saw the TPOIASI, or Terrible Problem Of Incrementing A Smart Iterator, that could incur a performance cost in code that uses range adaptors. Today, we’ll see how smart output iterators fare with the TPOIASI (spoiler: they have a way to avoid the problem). Now if you’re wondering what smart iterators, […]

The Terrible Problem Of Incrementing A Smart Iterator

Published February 12, 2019 - 0 Comments
smart iterator range C++

The Terrible Problem Of Incrementing A Smart Iterator (or TPOIASI) is a difficulty that arises when implementing smart iterators. But even if you don’t implement smart iterators, you may use them in a disguised form, now or in the future. And then, the TPOIASI might impact your code in a subtle manner. Since the world […]

Why You Should Use std::for_each over Range-based For Loops

Published February 7, 2019 - 0 Comments

Today’s guest post is written by Jon Kalb. Jon’s infrequently updated blog is // info and he podcasts with Phil Nash on Cpp.chat. For onsite training he can be reached at jon@cpp.training. I’d like start by thanking Jonathan for creating and maintaining the Fluent{C++} blog, for the conversations that it spawns, and for letting me […]

The SoA Vector – Part 2: Implementation in C++

Published December 21, 2018 - 0 Comments

Today’s guest post is the second part of a two-posts series written by Sidney Congard. Sidney is an almost graduated student and an intern at QuasarDB, a company writing it’s own database in C++17. He has been doing C++ in his free time regularly for two years. Also interested in writing on Fluent C++? Check […]

Overview of std::map’s Insertion / Emplacement Methods in C++17

Published December 11, 2018 - 2 Comments
insert_or_assign try_emplace map C++

Today’s guest post is written by @walletfox, one of the hitchhikers in the C++ galaxy, trying to navigate its dark corners by writing articles, creating Mostly Harmless cheat sheets and observing the following rules: “Don’t panic! Always carry a cheat sheet next to the towel. So long and thanks for all the fish.”. Interested in writing on Fluent C++ too? Submit your […]

Algorithms on Ranges

Published December 7, 2018 - 5 Comments

In a lot of cases, using STL algorithms in C++ code allows to make it more expressive. However, some developers reported to me they had a hard time diffusing the usage of the STL in their companies, as their co-workers weren’t always keen on putting the STL in their daily coding toolbox. There were several […]

1 4 5 6 7 8 12