If a function calculates a value that can be calculated at the 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 the compile time.
So if the function value can be calculated at the compile time, it means that the parameters in the
function function call must be value can be calculated at the compile time.
So it means that the parameters uh, in a function must be known at compile time, and so they must
be literal.
So the function must also be a single line.
So if there is if these restrictions are not met, then the compiler is free to ignore the specified.
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.
So the related in this in line specify that this can be placed on the left of a function here.
In line.
This kind of the left of a function, the function declaration as a suggestions 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 we only indicate that the function has completed correctly so there's no requirement that the
column 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.
This function is so simple that is good candidate to be inline.
So the return type on the left is given out here, meaning that the actual return type is specified
after the parameter list and this operator and int 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 like 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 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 note 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 calls into a never ending loop
to pull some value.
So if it does not return value at all, you can mark it with the C++ 11 attribute, the no return no
return attribute with this here.
So the compiler can use this attribute to read write a more efficient code because it knows that it
does not need to provide the return value here.