Hello,
I have a question that can be deducted from the title. When to use C++ inline functions and when not? Should I declare my constructors/destructors as inline? Should I declare functions that have at least a loop as inline? People say that declaring small functions as inline is a good idea, what does small mean? 2 lines of code? 15 Expressions? 10 Instructions? What exactly makes a function small?
I don't believe that code lines count matters in C++ since you can be really compact. I think it's rather about expressions count that makes a function big or small because no matter how compact your code is, it will still be cut in pieces when it's translated into machine code. Expressions are contained by instructions and an instruction can have more than one expression. For instance:
char a[10][10] = {0}, i = 0;
int main(){
a[++i][i++] = 1;
return 0;
}
Will be translated, just the main() body without return, into (ASM):
INC i
MV a[i*10][i], 1
INC i
That's why I say expression count is the one that dictates actual function size.
What do you guys think?