質問

So I'm very new to Boost but I'm running into problems trying to do some of the most basic of things in my win32 application project in vs2010.

I have gone into my vs2010 project properties and made sure that my include files are looking in the right places, and when I build I don't get errors including hpp files from boost in my stdafx.h, however when I read the documentation on their site here: http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/spirit/support/multi_pass.html I just get a bunch of basic errors like multi_pass is undefined.

I only need boost for one thing, and that is to create a forward operator from my current input operator so I can pass it through a function. Below is the declaration for my input operator.

std::istreambuf_iterator<char> eof;

I found an alternative solution on that same page where the std::basic_istream_iterator is actually a forward operator but when I compile I get an error saying that basic_istream_iterator is not part of the std library.

In the end I'm just really new to iterators themselves and boost. I would like to know how I can get my input iterator transformed into a forward iterator so I can iterator through a file.

役に立ちましたか?

解決

Like the commenter siad, you need to include the right support headers.

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>

Howeever, the simplest way is:

 std::ifstream file("myfile.txt", std::ios::binary);
 file.unsetf(std::ios::skipws);

 // use the ready-made:

 boost::spirit::istream_iterator f(file), l;

 // parse!
 book ok = qi::parse(f, l, my_grammar);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top