Toying with Boost.Spirit, I did set up iterators for my file-to-be-parsed: Boost's variant of istream_iterator to get proper forward iterators as required by Spirit, wrapped in line_pos_iterator for better error messages.
At this point I am looking at code like this:
#include <boost/spirit/include/support_istream_iterator.hpp>
#include <boost/spirit/include/support_line_pos_iterator.hpp>
#include <iostream>
#include <fstream>
int main()
{
std::ifstream input( "test.txt" );
input.unsetf( std::ios::skipws );
boost::spirit::istream_iterator foo_begin( input );
boost::spirit::istream_iterator foo_end;
boost::spirit::line_pos_iterator< boost::spirit::istream_iterator > bar_begin( foo_begin );
boost::spirit::line_pos_iterator< boost::spirit::istream_iterator > bar_end( foo_end );
// ...
}
I am thinking there should be a cleaner way to do this declaration, hopefully avoiding the introduction of two irrelevant, temporary identifiers (foo_*).
I am not really familiar with the new declaration syntax variants of C++11, and would like to ask those who know:
Can the bar_* iterators in the code above be declared in a more terse way, avoiding the foo_* temporaries?
Aucun commentaire:
Enregistrer un commentaire