xieite::read()

Defined in fragment xieite:read
(header-only: <xieite/io/read.hpp>)


Reads the entire contents of an input stream to a std::string.


Declaration

#0
std::string read(std::istream& stream) noexcept;
Uses std::istreambuf_iterator.

#1
std::string read(std::FILE* const stream) noexcept;
Reads the file stream in chunks, with the chunk size doubling every iteration.


Example

import std;
import xieite;

int main() {
	std::ofstream("msg.txt") << "Hello, world!";

	xieite::dump(xieite::read(xieite::tmp(std::ifstream("msg.txt"))));
}
Output:
Hello, world!