<div class="gmail_quote">On Sun, Jul 15, 2012 at 1:23 PM, Nathan Ridge <span dir="ltr">&lt;<a href="mailto:zeratul976@hotmail.com" target="_blank">zeratul976@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br></div>
I don&#39;t see why you insist on using phoenix::for_each.<br></blockquote><div><br></div><div>I&#39;m trying to gain an understanding of the phoenix library.  This is an easy example that I have in my code to tear apart.  I know the end result and there are only two functions that I&#39;m varying. </div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The advantage of phoenix::for_each over boost::for_each is that phoenix::<br>
for_each is lazy (it allows you to delay some of the arguments to be<br>
passed in later). You are not making use of that feature here - you are<br>
providing all of the arguments up-front, and as a result, you have to<br>
call the resulting delayed function with no arguments.<br></blockquote><div><br></div><div>True.  I&#39;m not taking full advantage of the Phoenix library.  I find it easier to know when to use a lazy for_each when I see how it plays with other things.</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You should only use the lazy version of a function when you are taking<br>
advantage of the fact that it&#39;s lazy; in other cases it&#39;s simpler to use<br>
the regular, non-lazy version. In this case, you need push_back() to be<br>
lazy, but not for_each(), so you are complicating things unnecessarily<br>
by using the phoenix version of for_each.<br></blockquote><div><br></div><div>I agree.  Again I view this as a learning experience.  If I started with a very complicated problem I might not understand the library enough to find the solution.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This works just fine, as I&#39;ve mentioned before:<br>
<br>
boost::for_each(tokens, phx::push_back(phx::ref(string_tokens), phx::arg_names::arg)));<br></blockquote><div><br></div><div>This will probably be the method I go with in the end.</div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Note that it is not inconsistent that you are using boost::for_each for<br>
one algorithm, and phoenix::push_back for another. The phoenix:: algorithms<br>
are exactly like the boost:: algorithms except that they add laziness.<br>
Since adding laziness complicates the interface of the function, it follows<br>
that you should only use the lazy version in instances where you actually<br>
need the laziness.<br></blockquote><div><br></div><div>I have no problem using the boost::for_each, std::for_each or the phoenix::for_each.  Unfortunately, I didn&#39;t understand the phoenix::for_each.</div><div><br></div>
<div>Ryan</div></div>

