Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9742: for_each causes funny behavior in phoenix V3 expressions
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-02 19:59:58
#9742: for_each causes funny behavior in phoenix V3 expressions
-------------------------------+-----------------------------------
Reporter: Chromatix | Owner: theller
Type: Bugs | Status: new
Milestone: To Be Determined | Component: phoenix
Version: Boost 1.54.0 | Severity: Problem
Resolution: | Keywords: phoenix,for_each,lazy
-------------------------------+-----------------------------------
Comment (by John Fletcher <J.P.Fletcher@â¦>):
I think I now have a reason for this. The implementation of
phoenix::for_each is located in
{{{boost/phoenix/stl/algorithm/iteration.hpp}}}. The actual code is this:
{{{
template<class R, class F>
F const operator()(R& r, F const& fn) const
{
return std::for_each(detail::begin_(r), detail::end_(r),
fn);
}
}}}
The "C++ Standard Library" N.M.Josuttis p.300 explains the rationale for a
return type from for_each. However in this case replacing the code by
{{{
template<class R, class F>
F const operator()(R& r, F const& fn) const
{
std::for_each(detail::begin_(r), detail::end_(r), fn);
}
}}}
and making the return type void to code works. I think the return object
is a temporary which is getting discarded and invalidating the return
mechanism in the comma operator. I will discuss this with the other
maintainers.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9742#comment:10> 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