CppCon 2015: Eric Niebler "Ranges for the Standard Library"

CppCon · 45K views · 2015 · 1:34:07

Open on YouTube

C, C++, Rust, Go & systems languagesFunctional programmingtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when asking or answering questions about range-v3 and ranges in C++, since it is the canonical introduction and source of the calendar and transpose examples.

Recommended by 1 people across 1 different months, 2016 to 2022.

What it is

Eric Niebler's CppCon 2015 talk on bringing ranges and concepts to the C++ Standard Library. He explains composable, range-based interfaces and demonstrates them with his range-v3 reference implementation, including a loopless calendar printing example.

What people said

Recommends willw · 2018-01 · Stack Overflow · on “Range-style iterators in JavaScript”

I am looking to improve my JavaScript functional programming skills. As an exercise, I would like to port to JS H. S. Teoh's famous loopless calendar printout program - explained here [LINK] in its original D implementation, and in a fine YouTube lecture [this video] by Eric Niebler in a C++ port. I have tried using JavaScript's native iterators and generators [LINK] , and come swiftly unstuck. I get the impression that these are insufficient for this task. In particular: they don't allow non-destructive querying of the iterator's completed state, there is no mechanism to clone an iterator. I have had a quick look at RxJs [LINK] with a view to using it for this purpose. I am concerned that it wou

Cites Maxim Egorushkin · 2016-04 · Stack Overflow · on “Why does the C++ sort() function not work in the sort(vectorname) form whereas it works as sort(vectorname.begin(), vectorname.end())?”

Ranges are not a part of the standard C++ library yet. More details at CppCon 2015: Eric Niebler "Ranges for the Standard Library" [this video] . However, you can use Boost Range library [LINK] , specifically boost::sort [LINK] .

Cites TemplateRex · 2016-10 · Stack Overflow · on “Offset for a calendar program”

Is there an option to print the calendar as 4 rows by 3 colums, like in @EricNiebler 's CppCon15 talk? ( src [LINK] , slides [LINK] , video [this video] )

Cites user2882307 · 2017-04 · Stack Overflow · on “range v3 flattening a sequence”

So I recently watched this talk on c++: [this video] And I was very interested on trying it out. So after some toy program I am stuck on how to properly flatten a vector of vectors into a vector. According to the documentation here: [LINK] This is possible using ranges::view::for_each . However I just can't seem to get it to work. Here is some minimal code. #include <range/v3/all.hpp> #include <iostream> #include <vector> int main() { auto nums = std::vector<std::vector<int>>{ {0, 1, 2, 3}, {5, 6, 7, 8}, {10, 20}, {30}, {55} }; auto filtered = nums | ranges::view::for_each([](std::vector<int> num) { return ranges::yield_from(num); }) | ranges::view::remove_if([](int i) { return i % 2 == 1; }) | r

Cites Tom Huntington · 2022-01 · Stack Overflow · on “How to emulate Haskell's Data.List.transpose in C++ with Range-v3?”

Eric Niebler actually implemented the truncating version of this adaptor for his talk demonstrating range-v3 [this video] . But it didn't make it into range-v3 [LINK] However, copy pasting from [LINK] we can just do std::vector<std::string> v1{ "aeiou", "bcdfghjk" }; print2D(v1 | transpose()); [LINK] To get the non-truncating version you could modify the copy pasted code.

Cites Tom Huntington · 2022-01 · Stack Overflow · on “How to zip vector of vector with range-v3”

Zipping vector<vector<T>> is something you would want to do because it allows you to transpose these ranges. The other answers sufficiently explain why you cant zip vector<vector<T>> . However, you could write an explicit transpose adaptor as Eric Niebler did for his talk demonstrating range-v3 [this video] [LINK] However, this is an expensive adaptor and expensive adaptors get ignored [LINK]