[Insight-developers] Rationalization of use of inline member function

Kent Williams kent at psychiatry.uiowa.edu
Thu Oct 12 13:52:31 EDT 2006


Right now I am working on changing several classes in ITK slightly. 

The Problem: Some functions are declared inline in the class 
declaration, but the function is defined in the corresponding TXX file.  
In the default state of an ITK build, this works fine, because the TXX 
file is included in the .H file.  But if Explicit Instantiation is 
turned on, the function has been declared in-line, but the TXX file is 
not included, so the function is not defined.

So what I'm doing is this -- moving inline member function definitions 
into the class header.   This shouldn't break anything -- it just moves 
the function definitions where they'll be available even if the TXX file 
is not included in the header.

What I'm noticing is that there's a style issue that needs to be 
addressed with regards to inline functions.

1. If the function is fully defined within the class definition, I 
thought the compiler would implicitly assume it to be an inline member 
function.  In that case, is the 'inline' keyword is redundant?
2. If the function is declared as inline, the definition of the function 
should always be included in the header, and not the TXX file.
3. What determines whether an inline member function is defined within 
the class definition, or defined in the header after the class has been 
defined? Is there some threshold number of statements/lines in the 
function definition that determines whether to move it out of the class 
definition?



More information about the Insight-developers mailing list