All posts in "STL"

Chaining Output Iterators Into a Pipeline

Published August 6, 2019 - 0 Comments

We’ve been over a various set of smart output iterators over the past few weeks. Today we explore how to combine them and create expressive code. If you’re just joining our series on smart output iterators, you might want to check out this introductory post on smart output iterators. So far, we’ve been combining smart […]

My C++Now Talk on Smart Output Iterators

Published August 2, 2019 - 0 Comments

If you’ve been reading Fluent C++ over the past few weeks, then you’ve noticed that we spent some time on smart output iterators. Those little components allow to write expressive code when it comes to applying operations on collections, and in particular when there are multiple outputs to those operations. When I was at the […]

How to Use is_permutation on Collections of Different Types

Published June 28, 2019 - 0 Comments

std::is_permutation is an STL algorithm that checks if two collections contain the same values, but not necessarily in the same order. We have encountered is_permutation in the STL algorithms on permutations, and we’ve seen how it was implemented. If you’d like a refresher on std::permutation, check out those two articles to get warmed up. Today we’re focusing […]

Understanding the implementation of std::is_permutation

Published June 25, 2019 - 0 Comments

Knowing your STL algorithms is a good thing. And knowing what’s inside of them is a great way to go further in their study. In that spirit, let’s dig into the implementation of std::is_permutation. It’s a nice algorithm to study, as it can be implemented by using other STL algorithms and it has some interesting […]

How to Send an STL Collection to a Curried Object

Published May 10, 2019 - 0 Comments
STL intersperse

After seeing how to send individual objects to a curried object, let’s see how we can haul a whole collection into one of those curried creatures. One use case for this is to intersperse a collection of strings with commas. If you’re jumping in the topic of curried objects just now, a curried object is […]

Performance benchmark: Ranges VS STL algorithms VS Smart output iterators

Published March 15, 2019 - 0 Comments

Ranges, STL algorithms and smart output iterators are three libraries that perform operations on collections and make code more expressive. Even if they have some specificities, like zip for ranges and unzip for smart output iterators for example, as we saw when combining ranges with output iterators, they also share features in common, such as transform and filter. […]

The Demultiplexer Iterator: Routing Data to Any Numbers of Outputs

Published March 12, 2019 - 0 Comments
demux demultiplexer iterator

In a previous post, we explored the partition output iterator, that routes data into two directions according to a predicate: the elements that satisfy the predicate to one side, and those that don’t to another side: auto const isEvenPartition = partition([](int n){ return n % 2 == 0; }); std::copy(begin(input), end(input), isEvenPartition(back_inserter(evenNumbers), back_inserter(oddNumbers))); The above code […]

Partitioning Data with Output Iterators in C++

Published March 1, 2019 - 0 Comments

A couple of months (or years?) back, we saw that partitioning in the STL meant tidying up data according to a predicate: all that satisfy the predicate in one group, and all that don’t satisfy the predicate in another group: This is what the STL algorithms std::partition (or std::stable_partition to keep the relative order of elements) do: auto […]

1 3 4 5 6 7 12