Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline const function

As inline function will replace the actual call from code, what is the use of calling inline function as const.

Inline void adddata() const {...}
like image 908
Swapnil Avatar asked Dec 09 '25 18:12

Swapnil


1 Answers

An inline function is one which can be defined in each translation unit, and must be defined separately in each translation unit where it is called. It is also a completely non binding suggestion to the compiler that you think the function should be inline. The compiler is free to actually inline or not inline any of your functions, whether or not they are declared inline.

const means that the object the function is a method of will tend not to be visibly modified by the function call. There are exceptions to this, it is always possible to modify if you try hard enough, but in general const is a promise to the caller that you won't.

Using them together means nothing additional to their individual meanings. They are essentially unrelated.

like image 156
Ethan Fine Avatar answered Dec 11 '25 08:12

Ethan Fine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!