[spirit.lex] 9580
Hi All, Can somebody take a look at bug #9580? It's a C++ puzzle. Two as if equivalent expressions demonstrate different behavior. This one auto expr = (this->self("SOME_STATE") += someTokenDef); calls boost::proto::detail::exprns_::operator +=. However this auto lex_def = this->self("SOME_STATE"); auto expr = (lex_def += someTokenDef); calls boost::spirit::lex::detail::operator +=. My guess is that it changes templates instantiaon order, but still I can't explain it and thus can't fix it. -- -- Vyacheslav Andrejev
Can somebody take a look at bug #9580? It's a C++ puzzle. Two as if equivalent expressions demonstrate different behavior. This one auto expr = (this->self("SOME_STATE") += someTokenDef); calls boost::proto::detail::exprns_::operator +=.
However this auto lex_def = this->self("SOME_STATE"); auto expr = (lex_def += someTokenDef); calls boost::spirit::lex::detail::operator +=.
My guess is that it changes templates instantiaon order, but still I can't explain it and thus can't fix it.
The first has an rvalue as its left hand side operand, while the second one uses an lvalue there. Not sure how to solve this after a cursory glance, though. Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu
HK> The first has an rvalue as its left hand side operand, while the HK> second one uses an lvalue there. How does it explain that neither of boost::spirit::lex::detail::operator += gets called? -- -- Vyacheslav Andrejev
HK>> The first has an rvalue as its left hand side operand, while the
HK>> second one uses an lvalue there.
HK>>
VA> How does it explain that neither of
VA> boost::spirit::lex::detail::operator += gets called?
Now I understand 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
participants (2)
-
Hartmut Kaiser
-
Vyacheslav Andrejev