No video

C++20 Ranges in Practice - Tristan Brindle - CppNorth 2022

  Рет қаралды 5,082

CppNorth

CppNorth

Күн бұрын

CppNorth Twitter: / cppnorth
CppNorth Website: cppnorth.ca/
---
C++20 Ranges in Practice - Tristan Brindle - CppNorth 2022
Slides:github.com/Cpp...
CppNorth 2022 video sponsors:
think-cell: www.think-cell...
Adobe: cppatadobe.spl...
Among the many new additions to C++20 are Ranges, a modern revision of the STL offering updated algorithms and new “views” with lazy evaluation.
In this example-based talk we’ll work through several practical demonstrations of how the new Ranges functionality may be used to solve everyday problems concisely, elegantly and efficiently. In addition, we’ll offer tips on how to avoid common errors in your Ranges code, and demonstrate a couple of useful utility functions which you can drop into your codebase today.
---
Tristan Brindle
Tristan is a freelance developer, trainer and WG21 member based in London, UK. He’s the author of NanoRange, an independent C++17 implementation of the C++20 ranges facilities, and various other open-source tools. He is also a director of C++ London Uni, a not-for-profit organisation offering free weekly C++ classes for students in London and around the world.
---
KZfaq Channel Managed By Digital Medium Ltd: events.digital...
---
#Programming​​ #CppNorth #algorithm

Пікірлер: 10
@Roibarkan
@Roibarkan Жыл бұрын
44:00 the change from call-operator to std::invoke is especially cool for projections, as it allows calling member functions or accessing data members simply by passing pointer-to-member as the projection. Great talk
@frydac
@frydac Жыл бұрын
Have yet to switch to C++20 (gcc format support, pls! and other stuff), this talk was just right for me, easy to follow and learned a lot! Thanks
@ChristianBrugger
@ChristianBrugger Жыл бұрын
A view is a range such that: * its move operations are constant-time * (if it is copyable) its copy operations are constant time * destruction of a moved-from object is constant-time * otherwise, destruction is O(N)
@ChristianBrugger
@ChristianBrugger Жыл бұрын
One of the best talk on ranges! Thank you. I know it's still very new, and I would love to see some discussion about performance numbers, as well as compile times. What to be careful about.
@ChristianBrugger
@ChristianBrugger Жыл бұрын
I had wrote one pipeline that took almost 10 seconds to compile and was 2-3 times slower than using algorithms. I am sure there are ways around this.
@thefullbridgerectifier
@thefullbridgerectifier Жыл бұрын
For the last problem (string trimming), I'd say an even cleaner way to do the trim function would be: auto trim() { return views::drop_while(::isspace) | views::reverse | views::drop_while(::isspace) | views::reverse; } handles both front and back trimming. Nice and elegant
@jonesconrad1
@jonesconrad1 Жыл бұрын
the dangling example at 11:00 ish, if ranges didn't do that ASAN would pick it up as a use after free.
@peregrin71
@peregrin71 Жыл бұрын
Shouldn't template std::string to_string(R& rng), need to constrain to R being a range of a char convertible type too?
@dawnadmin8119
@dawnadmin8119 Жыл бұрын
Makes me wonder if these first-class functors with composition are going to stay limited to range adaptors. It feels like Alice in Wonderland to have to write a singleton range, like {&x, &x+1}, just to use these abstractions on the base types of the language. I know it’s just a demo, but is a string-manupulation function that only works on 8-bit character sets really going to cut it in this century? Maybe there’s a need for a library that stores strings in some sensible form (UTF-8 NFD, stored in a dynamic array of char8_t), ensures that any data stored in it is in properly encoded, and then provides adapters to convert it to other formats. In this case, if there were a member that provided a view of the codepoints as a sequence of wchar_t objects, you could pass that to iswspace() and re-use most of the same logic. (Except on Windows, where wchar_t violates the Standard by not being a fixed-width encoding, so the standard library might break on UTF-16 surrogate pairs.) This lazy conversion through iteration over a range could be much more efficient than eagerly converting the UTF-8 string to a wide string, processing that, and converting back. (In a library that needs to remain thread-safe even if some other thread concurrently changes the global locale to one with a different definition of whitespace, you would also need a locale parameter, which could default to the one that was global at the time of the call But that isn’t related to your main topic.)
@ChristianBrugger
@ChristianBrugger Жыл бұрын
There is a lot of discussion about strings at the moment. See the std::print for example. One problem is that the standard iterator model of 1-by-1 doesn't work anymore and also is inefficient. So they are gona change it starting with replacing std::cout. I am sure more will come, once we have that in place.
Forward Progress in C++ - Olivier Giroux - CppNorth 2022
1:17:01
The Best Parts of C++ - Jason Turner - CppNorth 2022
1:01:08
CppNorth
Рет қаралды 9 М.
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 110 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:40
CRAZY GREAPA
Рет қаралды 39 МЛН
C++ Lambda Idioms - Timur Doumler - CppNorth 2022
1:03:57
CppNorth
Рет қаралды 5 М.
Rust Axum Production Coding (E01 - Rust Web App Production Coding)
3:53:02
New Algorithms in C++23 - Conor Hoekstra - CppNorth 2023
1:29:56