They're equivalent class definitions except for the purposes of the One Definition Rule. So the standard does not guarantee that you can compile one TU (translation unit) with one class definition and a different TU with the other, and then link them together. I doubt that this would ever actually fail on a real implementation, but that's what the standard says.
The inline
keyword has approximately nothing to do with inlining. It's about whether multiple identical definitions of the function are permitted in different TUs. If someone moves the function definition elsewhere, then they should decide whether to mark it inline
on the following basis:
If it is in a .cpp
file for that class, then it's valid to mark it inline
if it's called only from that TU. Then it probably makes no difference whether it is marked inline
or not, but you could mark it inline
as a compiler hint if you think the compiler will pay any attention to what you want.
If it is still in the header file, then it must be marked inline
, or else you'll get multiple definition errors when linking different TUs that use the header.
Assuming that the person moving the function knows those things, I don't think they need a reminder in the class definition. If they don't know those things, then they probably have no business moving the function, but it would be safer for them to have an inline
keyword to move with it.