№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Название |
---|
It's nice to see something like @lru_cache implemented in C++. Thanks very much, the blog is great!
Btw, what is the version of C++ that you used?
I'm glad to know that you liked it! I used C++20 when I submitted a few years back, but it works in C++17 too (relevant submission).
In C++ 23, you could use 'deducing this' for lambda recursion.
By the way, the way in which we implement recursive lambdas in C++17-20 is just the continuation passing style, which is also how the design of the cache is done in the blog.
C++23 makes it a language feature (in the form of syntactic sugar) but it still remains a special case. It will definitely help and encourage more people to write recursive lambdas, though.
most important types that we will ever need to hash: ...sets, maps ...
it is worth noting that for equals unordered_sets this hasher can return different values
Thanks for pointing this out. I used the phrase "sequence types" (and not container types) for this precise reason. The (unqualified) default
set
andmap
in C++ are ordered and will always give the same hash.The implementation, however, doesn't prevent you from using unordered versions of these, so you should indeed take care that you're not plugging them in anywhere.