Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

First of all, it seems that you've got a using namespace std; somewhere in your code. Don't do that Don't do that. (No, really No, really).

Here's a function that should meet your needs.

static std::string Read(std::istream &stream, std::string::size_type count)
{
 std::string out;
 out.reserve(count);
 std::copy_n(std::istreambuf_iterator(stream), count, std::back_inserter(out));
 return out;
}

First of all, it seems that you've got a using namespace std; somewhere in your code. Don't do that. (No, really).

Here's a function that should meet your needs.

static std::string Read(std::istream &stream, std::string::size_type count)
{
 std::string out;
 out.reserve(count);
 std::copy_n(std::istreambuf_iterator(stream), count, std::back_inserter(out));
 return out;
}

First of all, it seems that you've got a using namespace std; somewhere in your code. Don't do that. (No, really).

Here's a function that should meet your needs.

static std::string Read(std::istream &stream, std::string::size_type count)
{
 std::string out;
 out.reserve(count);
 std::copy_n(std::istreambuf_iterator(stream), count, std::back_inserter(out));
 return out;
}
changed type of count
Source Link
ruds
  • 3.4k
  • 17
  • 23

First of all, it seems that you've got a using namespace std; somewhere in your code. Don't do that. (No, really).

Here's a function that should meet your needs.

static std::string Read(std::istream &stream, uint32_tstd::string::size_type count)
{
 std::string out;
 out.reserve(count);
 std::copy_n(std::istreambuf_iterator(stream), count, std::back_inserter(out));
 return out;
}

First of all, it seems that you've got a using namespace std; somewhere in your code. Don't do that. (No, really).

Here's a function that should meet your needs.

static std::string Read(std::istream &stream, uint32_t count)
{
 std::string out;
 out.reserve(count);
 std::copy_n(std::istreambuf_iterator(stream), count, std::back_inserter(out));
 return out;
}

First of all, it seems that you've got a using namespace std; somewhere in your code. Don't do that. (No, really).

Here's a function that should meet your needs.

static std::string Read(std::istream &stream, std::string::size_type count)
{
 std::string out;
 out.reserve(count);
 std::copy_n(std::istreambuf_iterator(stream), count, std::back_inserter(out));
 return out;
}
Source Link
ruds
  • 3.4k
  • 17
  • 23

First of all, it seems that you've got a using namespace std; somewhere in your code. Don't do that. (No, really).

Here's a function that should meet your needs.

static std::string Read(std::istream &stream, uint32_t count)
{
 std::string out;
 out.reserve(count);
 std::copy_n(std::istreambuf_iterator(stream), count, std::back_inserter(out));
 return out;
}
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /