title: Unit test private methods by making them free functions
body: <p>In the 2017 cppcon videos, I came across a talk by Klaus Iglberger which was entitled "<a href="https://www.youtube.com/watch?v=WLDT1lDOsb4&amp;feature=youtu.be&amp;t=19m1s" rel="nofollow noreferrer">Free Your Functions!</a>". 
  In this talk, the speaker talked about how switching to free functions could 
  easy up the process of testing private methods (See at 19:00). The idea is that you pull the 
  private method out of the class (you make it a free function) and it becomes testable.</p>
  
  <p>At first, I found the idea interesting, but then the
  more I thought about it, the less I understood how this is actually supposed to work. For example,
  let's say I have the following (dummy) class:</p>
  
  <pre><code>class SomeClass
  {
  public:
      SomeClass();
      ~SomeClass();
  
      void someTask();
  
  private:
  
      void someComplexTask();
      void someOtherComplexTask();
  
  };
  
  void SomeClass::someTask()
  {
      someComplexTask();
      someOtherComplexTask();
  }
  
  // private tasks implementations...
  </code></pre>
  
  <p>Then <code>someComplexTask()</code> and <code>someOtherComplexTask()</code> are private methods. This means that they 
  are implementation details, i.e. that they can only be called inside <code>SomeClass</code> (or friends). It
  seems to me that if you make them free functions, yes they become testable, but they are no longer
  private, nor a mere implementation detail specific to <code>SomeClass</code>. In fact, they can be called from anywhere in the code...</p>
  
  <p>So my question is: why is Mr. Iglberger's point valid?</p>