On Jan 15, 9:19 am, "Igor R." <igor.rubi...@gmail.com> wrote:
> What's the laconic and standard way to do the subj - without an
> explicit loop of [allocate-read-write]?
If you're really committed to doing it without a
loop, then something like this will do it:
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>
using namespace std;
void
append_file_to_stream(ofstream& out, const char *infile)
{
ifstream in(infile, ios_base::in | ios_base::binary);
in.exceptions(ios_base::badbit | ios_base::failbit);
istreambuf_iterator<char> in_it(in);
istreambuf_iterator<char> end;
ostreambuf_iterator<char> out_it(out);
copy(in_it, end, out_it);
}
int main()
{
ofstream out("outfile.bin", ios_base:

ut | ios_base::binary);
out.exceptions(ios_base::badbit | ios_base::failbit);
append_file_to_stream(out, "infile1.bin");
append_file_to_stream(out, "infile2.bin");
}
It's got a certain charm, but I've never really used this
kind of thing in real code, so YMMV.
Sean