[Spirit] file_iterator confusion

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 <char_t> 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 <char_t> 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<iterator_t, iterator_t> 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]

Angus Leeming wrote:
I am just beginning to look at the spirit library, but am confused by the way file_iterator is working. [snip] 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.
Sorry, but did you forgot to attach your sample code? Or is it my mail client, which couldn't find it? Anyway, if you'd send it to me, I'd try to look at your problem. Regards Hartmut

HartmutKaiser@t-online.de wrote:
Angus Leeming wrote:
I am just beginning to look at the spirit library, but am confused by the way file_iterator is working. [snip] 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.
Sorry, but did you forgot to attach your sample code? Or is it my mail client, which couldn't find it? Anyway, if you'd send it to me, I'd try to look at your problem.
Regards Hartmut
Mny thanks, Hartmut. It appears that attachments are removed. I will send you the sample code this evening. Regards, Angus
participants (2)
-
Angus Leeming
-
HartmutKaiser@t-online.de