If a function calculates a value that can be calculated at compile time, you can mark it on the left
of the declaration with the.
For example, const expression here like this.
Here with this the you're going to indicate that the compiler can optimize the code by computing the
value at a compile time.
So if the function value can be calculated at compile time, it means that the parameters in the function
function call must be value can be calculated at compile time.
So it means that the parameters, uh, in the function must be known at compile time and so they must
be literal.
So the function must also be single line.
So if there is, if these restrictions are not met, then the compiler is free to ignore, uh, the
specifier.
But if you just compile it, the compiler won't say nothing here, but probably it will ignore the if
these restrictions are not met.
Uh, so the related in this inline specifier that, uh, this can be placed on the left of a function
here.
Inline.
This can replaced the left of a function.
Function declaration as a suggestion to the compiler that when other code call.
Calls this function rather than rather than the compiler inserting a jump to the function in memory,
the compiler should put a copy of the actual code in the calling function.
Again, the compiler is free to ignore specifiers if this restrictions is not met.
Here.
So we're going to determine the return type here.
So the functions may be written to run a routine and not a return value.
So if this case this is the case, you must specify that the function returns the void here.
Void here.
But in this case, you're going to see error because we are returning something, right?
So in most cases, a function will return a value.
So if only indicate that the function has completed correctly.
So there's no requirement that the calling function obtains the return value or does anything with it.
So the calling function can simply ignore the return value.
So there are two types, two ways to specify the return type.
The first way is to give the type before the function name like this.
In this case, this is an integer that returns integer, and this is the method used in most examples
in this course so far.
The second way is calling the trailing return type and requires that you place auto here auto as a return
type before the function function name as and use the this syntax here like this.
Integer.
We use the syntax to give the actual return type after the parameter list.
So.
Uh, this function is so simple.
That is a good candidate to be inlined.
So the return type on the left is given auto here, meaning that the actual return type is specified
after the parameter list and this operator.
And it means that the return type is an integer.
And this syntax has the same effect as using the integer on the left.
So.
But this is nice.
This is useful when a function is templated and the return type may not be noticeable here.
So in this trivial example, you can omit the return type entirely and just use the auto on the left
of the function name.
So this syntax means that the compiler will deduce the return type from the actual value returned.
So clearly the compiler will know, will only know what return type is from the function body, so you
can not provide a prototype for such functions.
So finally, if a function does not return at all, for example, if it goes into a never ending loop
to pull some value.
So if it does not return a value at all, you can mark it with the C plus plus 11 attribute, the no
return, no return attribute with this here so the compiler can use this attribute to read write more
efficient code because it knows that the it does not need to provide the return value here.