Reputation: 63737
The following innocuous function fails to compile on Solaris Studio 12.3
#undef _RWSTD_NO_MEMBER_TEMPLATES
#include <fstream>
#include <string>
#define _RWSTD_NO_MEMBER_TEMPLATES
std::string FetchData(const std::string& fname)
{
std::ifstream fin(fname.c_str());
std::string data;
if (fin)
{
data = std::string((std::istreambuf_iterator<char>(fin)),
std::istreambuf_iterator<char>());
}
return data;
}
int main()
{
return 0;
}
which fails with the error message
Could not find a match for
std::string::basic_string(std::istreambuf_iterator<char, std::char_traits<char>>, std::istreambuf_iterator<char, std::char_traits<char>>)
needed inOOTest::FetchData(const std::string &)
.
Now I checked the file std::string
and found the following
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
template <class _InputIterator>
basic_string (_InputIterator, _InputIterator, const _Allocator& _RWSTD_DEFAULT_ARG(_Allocator()));
SO I guess, std::string
has a declaration for the overload
template< class InputIt >
basic_string( InputIt first, InputIt last,
const Allocator& alloc = Allocator() );
which should have matched
template< class InputIt >
basic_string( InputIt first, InputIt last,
const Allocator& alloc = Allocator() );
but unfortunately it didn't.
So I have two questions
std::istreambuf_iterator<char>
doesn't match?_RWSTD_NO_MEMBER_TEMPLATES
for?Note
CC -E test.cpp > pre.out
and found, the iterator version was not generated. So I tried undefining _RWSTD_NO_MEMBER_TEMPLATES
but that didn't help.Upvotes: 0
Views: 1176