"I think that it's extraordinarily important that we in computer science keep fun in computing."
-- Alan J.Perlis
Dedication, SICP
https://www.youtube.com/watch?v=7oV7hiAsVTI
#cppcon #cpp #SICP
@codewiz are the `auto` for "our types are too long to type" or "we are just lazy" ? π
@Matthieu Answering your question requires introducing certain... concepts π
@Matthieu Ok, I must do it. It's too elegant. Too beautiful.
That auto in the parameter list is a C++20 shortcut syntax for templates:
template<typename T>
auto fib(T n) {
...
}
He says "C++20 concepts" in the slide because you could also throw in a concept right there:
auto fib(std::integral auto n) {
...
}
And this would _still_ be a template function, just not one that accidentally concatenates strings just because they had an operator+()
@codewiz I just had to do it:
http://ix.io/2B03/cpp
It's like exactly the same trick he used with the a and b to optimize fibonacci, except in case of self reference you actually need that trick cause the lambda does not have a type name, while a and b are states and as such belong in the capture list more than the self reference. Sooo much angeeer!
@namark @Matthieu He wanted to show that you could do a recursive lambda... It captures itself with [&] π