Cover art for podcast Take Up Code

Take Up Code

303 EpisodesProduced by Take Up Code: build your own computer games, apps, and robotics with podcasts and live classesWebsite

Take Up Code is a podcast that explains computer programming topics through fun and engaging examples that you can relate to. The guided format allows you to gain valuable understanding of topics that will reinforce your studies, allow you to train new skills that you can apply on your job, and chan… read more


261: CppCon: Interview With Conor Hoekstra About C++ Algorithms And Ranges.

This is an interview with Conor Hoekstra about C++ algorithms and ranges.

Conor presented my favorite talk at CppCon 2019 called Algorithm Intuition. I asked him to talk about algorithms on this podcast and he agreed. This just proves again why CppCon is the best place to be when you want to improve your C++ skills. The presenters were all going beyond just getting up on stage and answering a few questions. They’re real people who are willing to talk and mingle and generally help out in many ways.

If you’d like to improve your coding skills, then browse the recommended books and resources at the Resources page. You can find all my favorite books and resources at this page to help you create better software designs. Most of the ideas discussed in this episode will only come in C++20 and there are no books that I know of yet that focus on C++20. You can learn about the existing STL algorithms which will help you be prepared when C++20 is generally available.

Listen to the episode for more details or read the summary below.

Summary Have you given talks on algorithms at other conferences besides CppCon?

Conor gave versions of Algorithm Intuition at meetups in the Bay Area and in San Fransisco and then at conferences at CppCon 2019 and C++ Now in 2019.

What’s coming in C++ involving algorithms?

Conor is on the Canadian national body for ISO and he’s working on ranges in C++20 including 12 range adapters such as transform and reverse. There will be more range adapters being added in the future from the range-v3 library.

Conor works with other languages beyond C++ and there are range adapters included in these other languages. So it’s important to get the naming correct in C++ so people will know what to expect. We should follow precedence if possible that’s already been established.

Conor hopes to influence C++23, C++26, and C++29. Yes, C++29 comes up in committee meetings. This is because certain additions are optimistically targeting C++26 but might not arrive until C++29. ISO is definitely working towards a long term future.

What are the major changes coming in C++ algorithms?

There are two different things coming with ranges.

  1. The changes are more than updated algorithms that take data structures instead of iterator pairs. The new range based algorithms let you pass collections directly instead of begin() and end().
  2. The second part is a new piping syntax that lets you send the output from one algorithm into the next algorithm. This comes currently with adapters and potentially in the future with actions.

There will be more range adapters coming that will work with both of these changes.

What is piping syntax?

Most Linux systems let you pipe the output from one command and send it to another command. This lets you compose commands by chaining them together. The same syntax is used for algorithms. The pipe is the vertical bar symbol on your keyboard. For US based keyboards, this is right above the enter key.

As an example consider the need to calculate the number of unique words in a list. Ignoring for a moment the std::unique algorithm, how could this be done by composing other algorithms together?

First sort the list, then group the result, then take the head, and finally count the result.

For example, if you start with the collection a b c a b c a b c, then sorting will give you a a a b b b c c c. Going into the group algorithm will split the collection into a list of separate lists a a a, followed by b b b and then c c c. And then taking the head of each sublist gives you a collection with just a, b, and c. You can then count the items in the last result to get the answer.

This is difficult to do today without using std::unique. With the new range-v3, it’s easy to take the initial list, pipe it to sort, pipe it to group, pipe it to transform_head, and then pipe it to length.

If you need to learn just a handful of C++ algorithms, what would they be?

There’s one algorithm that’s most under appreciated. And that’s the algorithm std::accumulate. Ben Deane gave a talk previously at CppCon 2016 called “std::accumulate: Exploring an Algorithmic Empire”.

In this talk, Ben showed that almost all the standard algorithms can be implemented using std::accumulate. In other languages, this might be known as a fold or a reduce operation. This takes a list of items and reduces it down to a single item.

For example, std::max_element and std::min_element are both reducing algorithms. The default operation for std::accumulate is std::plus. But if you replace this default operator with std::max or std::min, then you get the same result as std::max_element and std::min_element.

What final recommendations do you have?

Conor recommends learning a new programming language each year. You don’t need to become an expert. A little knowledge will help you to write better C++ code.

Educational emoji reaction


Interesting emoji reaction


Funny emoji reaction


Agree emoji reaction


Love emoji reaction


Wow emoji reaction


Are you the creator of this podcast?

Verify your account

and pick the featured episodes for your show.

Listen to Take Up Code


A free podcast app for iPhone and Android

  • User-created playlists and collections
  • Download episodes while on WiFi to listen without using mobile data
  • Stream podcast episodes without waiting for a download
  • Queue episodes to create a personal continuous playlist
RadioPublic on iOS and Android
Or by RSS
RSS feed

Connect with listeners

Podcasters use the RadioPublic listener relationship platform to build lasting connections with fans

Yes, let's begin connecting
Browser window

Find new listeners

  • A dedicated website for your podcast
  • Web embed players designed to convert visitors to listeners in the RadioPublic apps for iPhone and Android
Clicking mouse cursor

Understand your audience

  • Capture listener activity with affinity scores
  • Measure your promotional campaigns and integrate with Google and Facebook analytics
Graph of increasing value

Engage your fanbase

  • Deliver timely Calls To Action, including email acquistion for your mailing list
  • Share exactly the right moment in an episode via text, email, and social media
Icon of cellphone with money

Make money

  • Tip and transfer funds directly to podcastsers
  • Earn money for qualified plays in the RadioPublic apps with Paid Listens