Victor
Language: g++ Source: #include <iostream> auto main() -> int { std::cout << "Hello World" << std::endl; return 0; } Result: Hello World
Victor
Language: g++ Source: #include <iostream> auto main() -> decltype(123) { std::cout << "Hello World" << std::endl; return 0; } Result: Hello World
Anonymous
I'm sure this will work in every implementation which supports modern standards
S.
Well... not so surprised
Anonymous
It's no magic, but it looks silly and more cpp'ish
Walter
Field application engineer or software developer which domain has a better value??
S.
Hi guys. Is there an elegant way to do reverse iteration in range-based for loop? Checked google but not satisfied with the answer: https://stackoverflow.com/q/8542591/824501
S.
I mean, is there any built-in function so that I can write for (auto& i: built_in_reverse(something)) {...}
S.
Hmm, std::reverse maybe?
does it modify the content?
S.
or is it slow?
Anonymous
does it modify the content?
https://en.cppreference.com/w/cpp/algorithm/reverse
Anonymous
It does, and I think it's as performant as it can be
S.
It does, and I think it's as performant as it can be
Hmm then it's not equivalent to reverse iteration
S.
So we still have to write for (auto p = v.rbegin(); p != v.rend(); ++p) instead, it seems
Victor
boost::adaptors::reverse
Anonymous
Hmm then it's not equivalent to reverse iteration
Maybe something like for (vector<foo>::reverse_iterator i = bar.rbegin(); i != bar.rend(); ++i)
S.
boost::adaptors::reverse
already seen that stackoverflow answer but ... hasn't the standard implemented its own one
Anonymous
I'm not sure if every container implements reverse_iterator, but its the last idea I can get
Anonymous
I'm not sure if every container implements reverse_iterator, but its the last idea I can get
Hmm std::reverse_iterator<> works on every iterator except stashing iterators it seems
Victor
not a ranged-based for, definitely, not even for loop
Anonymous
Thanks, it's so javascript!
Mhmm, it's so easy to write unreadable code in cpp. I mean, it uses modern features but it's ugly as fuck
S.
( I'd rather read IOCCC
Ahmed
Thanks
Ludovic 'Archivist'
Anonymous
Normally you would use ranges instead of the reverse iterator
How do you define "normally"? There are situations where you use the iterators and situations where you use ranges
Anonymous
I only think this example is more unreadable
Ludovic 'Archivist'
klimi
Yo big ludo
Ludovic 'Archivist'
Yo big ludo
Yo small kurimi
klimi
Yo small kurimi
You're supposed to say little not small
klimi
Ludovic 'Archivist'
You're supposed to say little not small
But u smoll thingy '-'
klimi
But u smoll thingy '-'
I got yesterday my gadgets
Ludovic 'Archivist'
do you have link?
https://www.fluentcpp.com/2018/02/09/introduction-ranges-library/
Parra
I saw boost has an extension like this:
Parra
for (auto i : irange(0, 10)) {}
Ludovic 'Archivist'
Parra
is std planing to do something like that?
Anonymous
Ranges are made to be replacement for iterators, as in complete replacement
Hmm, I still would use iterators if you need to iterate over every second element for example
Ludovic 'Archivist'
for(auto i : my_vec | range::view::reverse() )
Anonymous
Else I would agree, there are more situations where ranges are more elegant
Ludovic 'Archivist'
Else I would agree, there are more situations where ranges are more elegant
But that is mainly because iterators are truly not elegant
Tawanda
Anyone want to share c/ c++ projects I will be pleased github etc
Tawanda
Srsly don't be rude
Dima
Github offers you to take a look on projects you may be interested in
Tawanda
I just want inspiration as a young developer
Dima
you can take a look on my server https://github.com/luckyycode/neko-webframework
Dima
kek
Tawanda
Thax
Tawanda
May I finish it
Dima
no
Tawanda
OK
Dima
yus, still wip
MᏫᎻᎯᎷᎷᎬᎠ
Wip?
Dima
work in progress
MᏫᎻᎯᎷᎷᎬᎠ
Ooh
MᏫᎻᎯᎷᎷᎬᎠ
It's nice
MᏫᎻᎯᎷᎷᎬᎠ
You are great :)
Tawanda
That server is pretty stinking cool
Roxifλsz 🇱🇹
Dima
Roxifλsz 🇱🇹
Dima
top kek
Roxifλsz 🇱🇹
Indeed