Closed jojogh closed 4 years ago
seems no one would answer my question.
It seems like I experience a similar issue when using stateful terminals created from rvalue references. I'll have look if I can figure out what is going on...
many thanks
greole notifications@github.com 于2020年2月17日周一 上午1:19写道:
It seems like I experience a similar issue when using stateful terminals created from rvalue references. I'll have look if I can figure out what is going on...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/boostorg/yap/issues/101?email_source=notifications&email_token=AABCZJLIS5YJYPMJEWBPOO3RDFYRBA5CNFSM4KPR2LNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL4MYTI#issuecomment-586730573, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCZJOHJL22ARBCIMEGNFTRDFYRBANCNFSM4KPR2LNA .
struct eval
{
auto operator() (double a, double b) {
auto lhs_w = boost::yap::make_terminal<tarray_expr>(std::move(a));
auto rhs_w = boost::yap::make_terminal<tarray_expr>(std::move(b));
return lhs_w + rhs_w;
}
};
This returns a dangling reference to both lhs_w and rhs_w. The documentation explains why. If you std::move them both, as in return std::move(lhs_w) + std::move(rhs_w);
, your code will work as intended.
I want to use boost yap to do some small example, the codes are below, why I put the expression into an operator or member function in a structure, the two evaluation results are different? I am looking forward to your reply, many thanks! new4.cpp.txt