SRD

lamda

SRD
Jul 4th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. // Can lamda's be attached to grammar rules? E.g.,        
  2.  
  3.     x3::rule<class _desc> const _desc = "_desc";
  4.     auto const _desc_def = *(char_ - eol);
  5.     BOOST_SPIRIT_DEFINE(_desc);
  6.  
  7.     auto description = skip(blank) [
  8.         *(_desc >> eol)
  9.     ];
  10.  
  11.     auto process_desc = [&] (auto& ctx) {
  12.         std::cout << _attr(ctx) << std::endl;
  13.     };
  14.  
  15.     auto const input = description[process_desc];
  16.  
  17. /*
  18. By doing this, I get this error ...
  19.  
  20. test.cpp:48:42:   required from here
  21. /usr/include/boost/spirit/home/x3/core/call.hpp:72:28: error: use of ‘auto boost::spirit::x3::detail::call(F, const Context&, mpl_::true_) [with F = parser::smf::<lambda(auto:1&)>; Context = boost::spirit::x3::context<boost::spirit::x3::attr_context_tag, boost::spirit::x3::unused_type, boost::spirit::x3::context<boost::spirit::x3::where_context_tag, boost::iterator_range<boost::spirit::basic_istream_iterator<char> >, boost::spirit::x3::context<boost::spirit::x3::rule_val_context_tag, const boost::spirit::x3::unused_type, boost::spirit::x3::context<boost::spirit::x3::parse_pass_context_tag, bool, boost::spirit::x3::unused_type> > > >; mpl_::true_ = mpl_::bool_<true>]’ before deduction of ‘auto’
  22.          return detail::call(f, attr_context, is_callable<F(decltype(attr_contex
  23.                             ^
  24. */
Advertisement
Add Comment
Please, Sign In to add comment