/* """ quote
[snip]
Are you sure, you copied the code correctly? I am pretty sure
that I put the second iterator argument within yet another
pair of parentheses:
buffer the_buf ( std::istreambuf_iterator<char>( infile ),
(std::istreambuf_iterator<char>() ) );
^^^ ^^^
What you wrote is parsed as a function declaration.
There is (or was for the longest time---I haven't verified with
the most recent versions) a bug in g++, in that it "committed"
to the function declaration as soon as it saw that the first
argument could be interpreted as a declaration. So:
buffer the_buf ( (std::istreambuf_iterator<char>( infile )),
(std::istreambuf_iterator<char>() ) );
worked, but putting the parentheses only around the second
argument didn't.
""" */
[ GCC(MinGW)3.3.1 ]
// ref: ifstream PicIn( file, in | binary)
std::vector<unsigned char> Image(
( std::istreambuf_iterator<char>( PicIn ) ),
( std::istreambuf_iterator<char>() )
); // line 1946
// 1946 \TestBench.cpp syntax error before `)' token
[ Same with 'std::vector<char> Image(...', and '(PicIn.rdbuf())' ]
It works on Mr. Bux's GCC 4.2, so that 'bug' must have been fixed.
std::vector<unsigned char> Image(
std::istreambuf_iterator<char>( PicIn.rdbuf() ),
std::istreambuf_iterator<char>()
);
Works fine on my poor, tired old GCC.
/* """
I've gotten into the habit of putting it around all of them, so
I won't have noticed if they've fixed this. (Probably have. I
ran into it some time ago, and they tend to fix bugs pretty
quickly.)
""" */
I noticed, with or without the parentheses! <G>
At least now I know what was happening.
Thanks James.
Your other post; 'correct' was a very poor choice of wording on my part. I
was in a hurry (supper was ready!). :-}