Re: [Boost-bugs] [Boost C++ Libraries] #9580: [spirit.lex] self("state") += calls a wrong operator +=

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9580: [spirit.lex] self("state") += calls a wrong operator +=
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-30 15:52:29


#9580: [spirit.lex] self("state") += calls a wrong operator +=
--------------------------------------+---------------------
  Reporter: Vyacheslav Andrejev | Owner: hkaiser
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: spirit
   Version: Boost Development Trunk | Severity: Problem
Resolution: | Keywords:
--------------------------------------+---------------------

Comment (by Vyacheslav Andrejev):

 I found out what is going on. An rvalue cannot be bound to a non-const
 reference. `boost::spirit::lex::detail::operator+=` has a non-const
 reference as the first parameter and `this->self("SOME_STATE")` returns an
 rvalue. Therefore the compiler doesn't call
 `boost::spirit::lex::detail::operator+=`, but uses `template <typename
 Left, typename Right> operator +=(Left &&left, Right &&right)` from
 `boost::proto::expns_` instead. A solution could be adding another
 definition of `boost::spirit::lex::detail::operator+=`:
 {{{
 #!cpp
         // allow to assign a token definition expression
         template <typename LexerDef, typename Expr>
         inline lexer_def_<LexerDef>&
         operator+= (lexer_def_<LexerDef>&& lexdef, Expr&& xpr)
         {
             // Report invalid expression error as early as possible.
             // If you got an error_invalid_expression error message here,
             // then the expression (expr) is not a valid spirit lex
             // expression.
             BOOST_SPIRIT_ASSERT_MATCH(lex::domain, Expr);

             lexdef.define(xpr);
             return lexdef;
         }
 }}}

 Do we have some kind of virtual regression system I could test my changes
 in before forming a pull request?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9580#comment:4>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC