13:13 "Case-insensitive sorting is always a little bit tricky in C++" Just to hammer his point home, passing a raw char directly to std::toupper as he does in the slideware is actually wrong... you have to cast it to unsigned char before passing to std::toupper or you can run into undefined behavior on implementations where char is signed. But, you know, slide code and all...
Thank you for the talk, I read many things about lambdas in C++, but all the papers I had read don't explain the internals (class object with () operator) and without that it just looks like magic and you don't get all the implications of lambdas. So big thanks you for the talk.
Working through this in an IDE and the ranges lexicographical sort on slide 11 was vexing me for a while, but got it working. Slide code error... he's missed a semi-colon out after the return statement. If you amend the example to get it as the following, it will work: std::ranges::sort( v2, // Range to sort [](const std::string& s1, const std::string& s2) { // Sort criterion auto toUpper = [](char c) { return std::toupper(c); }; return std::ranges::lexicographical_compare( s1, // String as 1st range s2, // String as 2nd range std::less{}, // Compare criterion toUpper, // Projection for s1 element toUpper); // Projection for s2 element }); // End of sort statement
I couldn't understand the problem with having a function, why Lambdas? rewriting again and again may cause errors to creep in. testability.. it invalidates all basis of having a modular design.
Lambdas are cool-n-all, but very difficult to unit test. Apart from tiny lambdas to std algorithms within testable functions, I still prefer explicit function objects and function templates because of this.
Man I love this guy's talks/tutorials. Very simple very clear.
Nice, so many tiny details I didn't know or was confused about.
13:13 "Case-insensitive sorting is always a little bit tricky in C++" Just to hammer his point home, passing a raw char directly to std::toupper as he does in the slideware is actually wrong... you have to cast it to unsigned char before passing to std::toupper or you can run into undefined behavior on implementations where char is signed. But, you know, slide code and all...
clear , clean and powerful. very good tutorial, easy to understand in a few minutes. looking forward to see next.
Thank you for the talk, I read many things about lambdas in C++, but all the papers I had read don't explain the internals (class object with () operator) and without that it just looks like magic and you don't get all the implications of lambdas. So big thanks you for the talk.
i agree. I am trying to work through the code of these examples but it's more difficult since so much code was left out.
I recall using the STL long before C++11, back in the late 90s.
Explained well. Thanks for the quality content.
What a great talk!
Easy to understanding . Looking for next to meet.
Where can I get the slides of the talk?
Great talk!!! if i can get pdf file somewhere?
I have yet to remove the confusion between lambdas vs. generics vs. templates
I think the statement" My life would be better if my co-workers knew more C++" is true for everyone...
Working through this in an IDE and the ranges lexicographical sort on slide 11 was vexing me for a while, but got it working. Slide code error... he's missed a semi-colon out after the return statement. If you amend the example to get it as the following, it will work:
std::ranges::sort(
v2, // Range to sort
[](const std::string& s1, const std::string& s2) { // Sort criterion
auto toUpper = [](char c) { return std::toupper(c); };
return std::ranges::lexicographical_compare(
s1, // String as 1st range
s2, // String as 2nd range
std::less{}, // Compare criterion
toUpper, // Projection for s1 element
toUpper); // Projection for s2 element
}); // End of sort statement
Thankyou so much !!!
Very good as usual Nicolai. Slide 10: The "toupper" lambda should take "unsigned chars" to avoid UB in ? Same on slide 11...
I appreciate how he owns the fact that C++ is partially his fault. Self awareness majority of the commitee lacks.
Thanks for the session. Neatly explained..
I couldn't understand the problem with having a function, why Lambdas? rewriting again and again may cause errors to creep in. testability.. it invalidates all basis of having a modular design.
Is it ok to perceive lambdas calculus as symbolic math
In slide 11 we have two strings while lambda argument is char!
thanks sir, great presentation
You are most welcome
Lambdas are cool-n-all, but very difficult to unit test. Apart from tiny lambdas to std algorithms within testable functions, I still prefer explicit function objects and function templates because of this.
interesting and useful
“It’s partially all my fault”
Awesome.
Catching up with JavaScript! 😂
They are really like javascript features in C++, which looks kinda scaring to me
C++ introduced lambdas in 2011, Javacript in 2015 - if anything JavaScript is catching up to C++
I know I'm very late but even implying that lambda's originated with JavaScript hurts.