Тёмный
No video :(

Better C++ ranges - Arno Schödl - Meeting C++ 2023 

Meeting Cpp
Подписаться 32 тыс.
Просмотров 1,8 тыс.
50% 1

Better C++ ranges - Arno Schödl - Meeting C++ 2023
Ranges have been in the C++ standard for while now, and find their way into modern codebases. At think-cell, we have been developing and using our own range library for 20 years, which is built on top of the standard and is compatible with it, but goes beyond it in many aspects. Range adaptors are often stacked, a filter on top of a transform on top of etc. To make such a stack efficient, iterators are not good enough. We use a new concept that is more efficient and at the same time compatible with iterators so library users can keep using iterators as they did before. The standard library is very strict about the distinction between containers and views, and range adaptors are views which must maintain a reference to the data being adapted. Instead, we allow range adaptors to hold data themselves to make them self-contained and lazily evaluated at the same time. The standard iterator model only allows external iteration. However, internal iteration is often much easier to implement than external iteration. For many applications, internal iteration is completely adequate and more efficient than external iteration. Therefore, we bring internal iteration into the range family, to the point that the library user may not know or care which kind of iteration is being used. Standard algorithms return iterations and use the end iterator to signal some singleton state. By customizing return values, we can make our code more terse and expressive, for example eliminating these dreaded iterator end checks. These features combined make ranges an excellent tool for text formatting. We can use these ranges to represent the values to be formatted, conceptually turning them into lazily evaluated strings. These can be used just like regular strings are used today: in function returns; as standard algorithm input; embedded into other, equally lazily evaluated strings; and so on, before they are finally expanded for display. By choosing the right interfaces, we can optimize this expansion at compile-time, allowing both nice syntax and a performance which is very close to manually optimized code.

Опубликовано:

 

27 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 3   
@Roibarkan
@Roibarkan 8 месяцев назад
26:07 I like the notion of more flexible algorithm returns, and I think it resonates well with Stepanov “law of useful return”. I don’t understand why you prefer to make the ‘Pack’ strategy a template argument of the algorithms, instead of having the algorithms return an object with all the information, which can be ‘packed’ by the caller however they like.
@foonathan
@foonathan 8 месяцев назад
You save a branch. The `tc::find` does not require any extra branch to distinguish between the element/no element case to implement element_or_null. If you do it afterwards, you need to branch again on the algorithm result.
@AlfredoCorrea
@AlfredoCorrea 8 месяцев назад
Regarding the question at the end, it is possible to honor constness for some incarnations of ranges and, in general, for reference-like types. It is not impossible, but just very hard. One needs a disciplined overload of &, &&, and const& member functions and function arguments, even using still unconventionally idioms. The problem is that many experts think it is not worthy of attention and that it is a non-issue, and they justify this by giving a postmodern interpretation of what `const` means or simply giving up. We will pay dearly for this oversight; it will fragment conventions and make it hard, if not impossible, to write generic code (I mean Stepanov's Generic code). It would be great if TC (and others) took on this challenge, given all the other nice research they are doing.
Далее
Only I get to bully my sister 😤
00:27
Просмотров 28 млн
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Просмотров 4,8 млн
Oh No! My Doll Fell In The Dirt🤧💩
00:17
Просмотров 6 млн
Better C++ Ranges - Arno Schödl - [CppNow 2021]
1:09:08
Просмотров 2,5 тыс.
Why Function Pointers are Awesome
11:11
Просмотров 6 тыс.
C++ Weekly - Ep 342 - C++20's Ranges: A Quick Start
10:13