+ 2

Help me please understand do foo2() treated as inline or not

https://code.sololearn.com/cr9DgYo45J5J/?ref=app I know that if function defined as usual function but declared as inline (like foo()) it tells compile to treat it as inline, but what if vice versa?

6th Apr 2020, 12:51 AM
Денис Лапшин
Денис  Лапшин - avatar
3 Respuestas
0
I literally don’t know anything specific about this in c++ because it didn’t exist 20 years ago when I learned it. But it looks to me like syntactic sugar. Its like saying to compiler, “Treat this as inline, but I am moving it here because its bigger tgan I wanted it to be so this is more readable. But all the other code already expects ut to be inline.
12th Apr 2020, 10:22 PM
SQrL
SQrL - avatar
0
or the alternative, lambdas don’t exist in c++, but the lambda is syntactic sugar for an explicit declaration. At compile time lambdas get switched to this “inline” definition. Since the language can do it, technically so can you. Totally speculating based on the afe of c++ and that it would need to play bait and switch to pull off a real life lambda (and lambdas may be done this way in a lot of languages)
12th Apr 2020, 10:26 PM
SQrL
SQrL - avatar