title: Accessing member functions in templated container
body: <p>I want to be able to <code>&lt;&lt;</code> <code>val.first()</code> and <code>val.second()</code> element in 
  <code>struct Data&lt;std::pair&lt;F, S&gt;</code>. <code>F</code>, <code>S</code> should be generic in the sense that they can be anything specified like <code>struct Data&lt;int&gt;</code> (specific type). I don't know how to write the template for <code>struct Data&lt;std::pair&lt;F, S&gt;</code> in a way that allows it to only take <code>struct Data</code> as <code>F</code> or <code>S</code>.</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;utility&gt;
  
  template &lt;typename T&gt;
  struct Data;
  
  template &lt;typename T&gt;
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const Data&lt;T&gt;&amp; val) {
      return val(os);
  }
  
  template &lt;typename T&gt;
  Data&lt;std::remove_cv_t&lt;T&gt;&gt; data(const T&amp; val) { return { val }; }
  
  template &lt;&gt;
  struct Data&lt;int&gt; {
      std::ostream&amp; operator()(std::ostream&amp; os) const {
          os &lt;&lt; val;
          return os;
      }
      const int&amp; val;
  };
  
  //More struct Data for templatized types for other specific types
  
  
  template &lt;typename F, typename S&gt;
  struct Data&lt;std::pair&lt;F, S&gt; &gt; {
      std::ostream&amp; operator()(std::ostream&amp; os) const {
          os &lt;&lt; data(val.first()) &lt;&lt; data(val.second());
          return os;
      }
      std::pair&lt;F, S&gt; val;
  };
  
  //More struct Data templatized for other container types
  </code></pre>
  
  <p>The error when tested is:</p>
  
  <pre><code> error: called object type 'int' is not a function or function pointer
                      os &lt;&lt; data(val.first()) &lt;&lt; data(val.second());
                                 ^~~~~~~~~
  </code></pre>