I am reading learncpp's article on Inline functions, and it says that the modern goal of using inline functions is to avoid ODR errors.
That makes sense, it allows for a function to be defined in multiple files without changing it's name, and I can see why is that beneficial. But isn't that already achievable through forward declarations? Can't one just define the function in one CPP file and just do a forward declaration of it on the other files? (or a header file that is included in all the files that need access to that function).
While writing this post I realized that since compilers only "see" one translation unit at a time, this will result into the functions not getting inlined, which seemed to have answered the first part, but then throughout the article, the author says that the actual usage of inline to enhance performance is no longer seen to be a human task, and it is not defined in the standards, compilers may chose to ignore the inline keyword, and decide when to inline/not inline as they please, so the primary effect isn't even reliable, the only guaranteed effect is solving the ODR issue, which is already solvable by forward declarations.
What am I exaclty missing? Or is the answer as simple as: inline combines forward declarations effect + a possibility that the compiler follows what the human wants, so at worst case it is equal to forward declarations, and at best case that along with the performance enhancement?
There isn't much you are missing. You are only mixing up two differnt topics that aren't as much related as you think.
Its commonly recommended to place the definition in a source file (see eg Is it a good practice to place C++ definitions in header files?). If for whatever reason you decide to not follow that recommendation and you want to define the function right next to its declaration in the header, then you should declare the function inline
.
Can't one just define the function in one CPP file and just do a forward declaration of it on the other files?
If you want to define the function in a header, then not defining in the header is no solution. Also no forward declaration will help with that.
For reasoning on why you would want to define a function inline in the header see for example Benefits of header-only libraries or for more concrete examples Which Boost libraries are header-only?.