Hello.
I am just beginning to look at the spirit library, but am confused by the
way file_iterator is working.
Could anyone explain to me why this works:
typedef spirit::file_iterator iterator_t;
iterator_t first(argv[1]);
// check first is valid
...
iterator_t last = first.make_end();
but this doesn't:
typedef spirit::file_iterator iterator_t;
iterator_t first;
iterator_t last;
boost::tie(first, last) = open_file(argv[1]);
// check first is valid
...
Both codes compile, but only the first method results in the file being
read. In the second instance, the correct number of chars are read, but
only the first char is output (multiple times).
The open_file function is simply:
std::pair open_file(char const * name)
{
iterator_t first(name);
iterator_t last = first ? first.make_end() : iterator_t();
return std::make_pair(first, last);
}
Minimal sample code attached. My tests have been with boost 1.30.1.
Changing the line
#define FAILURE_MODE 1
toggles between the two cases.
Best regards,
Angus
[Non-text portions of this message have been removed]