Citing C++ Draft N4713:
Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program outside of a discarded statement (9.4.1); no diagnostic required. The definition can appear explicitly in the program, it can be found in the standard or a user-defined library, or (when appropriate) it is implicitly defined (see 15.1, 15.4 and 15.8). An inline function or variable shall be defined in every translation unit in which it is odr-used outside of a discarded statement.
In C++ versions prior to C++17, I can get around this restriction by just declaring my functions inline
. C++17 adds the same feature for variables.
Furthermore, it seems to me that the inline
-Keyword does not serve another purpose apart from making it possible to ignore the ODR.
So, why isn't this whole rule just abandoned for C++17 ? I can't see the purpose of a rule that can be turned off.