问题
Can Someone Please explain this Last line? I need to eventually determine if two vertexes are connected.
include <boost/fusion/adapted/std_pair.hpp>
include <boost/spirit/include/qi.hpp>
include <boost/graph/edge_list.hpp>
include <fstream>
typedef std::pair<int,int> Edge;
typedef std::vector<Edge> EdgeList;
typedef boost::edge_list<EdgeList::iterator> Graph;
namespace qi = boost::spirit::qi;
int main()
{
std::ifstream ifs("Graph.txt");
ifs >> std::noskipws;
//std::cout << ifs;
boost::spirit::istream_iterator f(ifs), l;
std::vector<Edge> edges;
bool parse_ok = qi::phrase_parse(f, l, (qi::int_ >> qi::int_) % qi::eol, qi::blank, edges);
Can some please explain this last line?:
bool parse_ok = qi::phrase_parse(f, l, (qi::int_ >> qi::int_) % qi::eol, qi::blank, edges);
回答1:
Looking at the documentation, looks like " The library provides a couple of free functions to make parsing a snap. These parser functions have two forms. The first form parse works on the character level. The second phrase_parse works on the phrase level and requires skip parser. Both versions can take in attributes by reference that will hold the parsed values on a successful parse." phrase_parse() is defined as
template <typename Iterator, typename Expr, typename Skipper>
inline bool
phrase_parse(
Iterator& first
, Iterator last
, Expr const& expr
, Skipper const& skipper
, BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip);
Maybe this is a good place to start.
来源:https://stackoverflow.com/questions/46802313/boost-graph-and-spirit