title: Interfaces with Template methods
body: <p>I need to define a Configuration object. I am using <code>boost::property_tree</code> for the impl, but I do not want to expose Impl details in my interface, or have to <code>#include</code> boost files in my interface. 
  The problem is that I would like to use the template method of ptree for getting values,  </p>
  
  <pre><code>template &lt;typename T&gt;
  T get(const std::string key)
  </code></pre>
  
  <p>But this is impossible (?)</p>
  
  <pre><code>// Non compilable code (!)
  // Interface
  class Config {
  public:
     template &lt;typename T&gt;
     T get(const std::string&amp; key);
   }
  
   // Impl
   #include "boost/property_tree.h"
  
  class ConfigImpl : public Config {
  public:
     template &lt;typename T&gt;
     T get(const std::string&amp; key) {
        return m_ptree.get(key);
     }
  
   private:
     boost::ptree m_ptree;
   }
  </code></pre>
  
  <p>One option is to limit the types I can "get", for instance:</p>
  
  <pre><code>// Interface
  class Config {
  public:
     virtual int get(const std::string&amp; key) = 0;
     virtual const char* get(const std::string&amp; key) = 0;
   }
  
   // Impl
   #include "boost/property_tree.h"
  
  class ConfigImpl : public Config {
  public:
     virtual int get(const std::string&amp; key) { return m_ptree.get&lt;int&gt;(key) };
     virtual const char* get(const std::string&amp; key) { return m_ptree.get&lt;const char*&gt;(key); }
  
   private:
     boost::ptree m_ptree;
   }
  </code></pre>
  
  <p>But this is pretty ugly and not scalable.<br>
  Any better options out there?</p>