title: Inline calls to non-inline base class functions (what does that mean exactly)?
body: <p>I'm reading through a C++ book and I'm in a section about reducing the object code generated by templates (<strong>Effective C++ III By Scott Meyers</strong>).  One of the examples it gives is:</p>
  
  <pre><code>template &lt;typename T, std::size_t n&gt;
  class SquareMatrix: private SquareMatrixBase&lt;T&gt; {
      public:
          SquareMatrix()
              : SquareMatrixBase&lt;T&gt;(n, 0),
                pData(new T[n*n])
          { this-&gt;setDataPtr(pData.get()); }
  
          ... functions ...
  
      private:
          boost::scoped_array&lt;T&gt; pData;
  };
  </code></pre>
  
  <p>where the base class, SquareMatrixBase has a function called:</p>
  
  <pre><code>void invert(std::size_t matrixSize);
  </code></pre>
  
  <blockquote>
    <p>"The book moves on to say "Regardless of where the data is stored, the
    key result from a bloat point of view is that now many -- maybe all --
    of SquareMatrix's member functions can be simple inline calls to
    non-inline base class versions that are shared with all other matrices
    holding the same type of data, regardless of their size."</p>
  </blockquote>
  
  <p>What does it mean by "inline calls to non-inline base class versions..."?  If its an inline call I would have thought it would have put the whole base class version of any function into the place where inline was used, but this would result in the same code bloat I would have thought.  It says this like it's a benefit against code-bloat though.</p>
  
  <p>If you need more background information let me know, the chapters long though and I tried pretty hard to provide background information but I might have missed something.</p>
  
  <h1> ||EDIT - Additional Information|| </h1>
  
  <p>The purpose of having Square Matrix and Square matrix base in this passage was:</p>
  
  <p>SquareMatrix was originally a standalone template (not derived). It contained a series of functions which did operations based on the template parameter n's value.  So, there was essentially a copy of every function for every value of n used (or for every pair of n, T used) as a new template with those functions was instantiated for each parameter pair.  SquareMatrixBase was created to move the functions dependent on the size parameter to the base class. Since the base class is only instantiated with a type parameter (and not the size) the functions in the base class can be called by passing in the value for size the derived class passes into the base class constructor.  This means there is only one version of the functions for each typename T passed into the SquareMatrix template regardless of the std::size_t n passed in (as opposed to one version of each function for each combination of {T, n}.</p>