title: Could not find a match for std::string::basic_string(std::istreambuf_iterator<char, std::char_traits<char>>, std::istreambuf_iterator<char, std::
body: <p>The following innocuous function fails to compile on Solaris Studio 12.3 </p>
  
  <pre><code>#undef _RWSTD_NO_MEMBER_TEMPLATES
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #define _RWSTD_NO_MEMBER_TEMPLATES
  std::string FetchData(const std::string&amp; fname)
      {
          std::ifstream fin(fname.c_str());
          std::string data;
          if (fin)
          {
              data = std::string((std::istreambuf_iterator&lt;char&gt;(fin)),
                  std::istreambuf_iterator&lt;char&gt;());
          }
          return data;
      }
  
  int main()
  {
      return 0;
  }
  </code></pre>
  
  <p>which fails with the error message</p>
  
  <blockquote>
    <p>Could not find a match for
    <code>std::string::basic_string(std::istreambuf_iterator&lt;char,
    std::char_traits&lt;char&gt;&gt;, std::istreambuf_iterator&lt;char,
    std::char_traits&lt;char&gt;&gt;)</code>needed in <code>OOTest::FetchData(const std::string
    &amp;)</code>.</p>
  </blockquote>
  
  <p>Now I checked the file <code>std::string</code> and found the following</p>
  
  <pre><code>#ifndef _RWSTD_NO_MEMBER_TEMPLATES
      template &lt;class _InputIterator&gt;
      basic_string (_InputIterator, _InputIterator, const _Allocator&amp; _RWSTD_DEFAULT_ARG(_Allocator()));
  </code></pre>
  
  <p>SO I guess, <code>std::string</code> has a declaration for the overload </p>
  
  <pre><code>template&lt; class InputIt &gt;
  basic_string( InputIt first, InputIt last, 
                const Allocator&amp; alloc = Allocator() );
  </code></pre>
  
  <p>which should have matched </p>
  
  <pre><code>template&lt; class InputIt &gt;
  basic_string( InputIt first, InputIt last, 
                const Allocator&amp; alloc = Allocator() );
  </code></pre>
  
  <p>but unfortunately it didn't.</p>
  
  <p>So I have two questions</p>
  
  <ol>
  <li>Why doesn't  my construction via <code>std::istreambuf_iterator&lt;char&gt;</code> doesn't match?</li>
  <li>What is this  macro <code>_RWSTD_NO_MEMBER_TEMPLATES</code> for?</li>
  </ol>
  
  <p><strong>Note</strong></p>
  
  <ol>
  <li>Based on the comment, I tried to generate the pre-processor output by running <code>CC -E test.cpp &gt; pre.out</code> and found, the iterator version was not generated. So I tried undefining <code>_RWSTD_NO_MEMBER_TEMPLATES</code> but that didn't help.</li>
  </ol>