<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: The One True Iterator Declaration</title>
	<atom:link href="http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/</link>
	<description>A company weblog</description>
	<pubDate>Fri, 29 Aug 2008 08:04:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: synss</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-4930</link>
		<dc:creator>synss</dc:creator>
		<pubDate>Thu, 29 Nov 2007 14:38:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-4930</guid>
		<description>The BOOST_FOREACH thing is precisely what I was looking for, though to shorten the line and increase genericity

BOOST_FOREACH(my_map::value_type &#38;data, my_map)
{
/* ... */
}

is better.</description>
		<content:encoded><![CDATA[<p>The BOOST_FOREACH thing is precisely what I was looking for, though to shorten the line and increase genericity</p>
<p>BOOST_FOREACH(my_map::value_type &amp;data, my_map)<br />
{<br />
/* &#8230; */<br />
}</p>
<p>is better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jbo5112</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-1418</link>
		<dc:creator>jbo5112</dc:creator>
		<pubDate>Wed, 15 Aug 2007 17:44:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-1418</guid>
		<description>okay, trying to do this without getting mangled (need a preview or edit button)...

using namespace std;

typedef string map_key_type;
typedef string map_value_type;

map&#60;map_key_type, map_value_type&#62; my_map;

BOOST_FOREACH( pair&#60;const map_key_type, map_value_type&#62; &#38;data, my_map )
{
// do your work on each pair here...
}</description>
		<content:encoded><![CDATA[<p>okay, trying to do this without getting mangled (need a preview or edit button)&#8230;</p>
<p>using namespace std;</p>
<p>typedef string map_key_type;<br />
typedef string map_value_type;</p>
<p>map&lt;map_key_type, map_value_type&gt; my_map;</p>
<p>BOOST_FOREACH( pair&lt;const map_key_type, map_value_type&gt; &amp;data, my_map )<br />
{<br />
// do your work on each pair here&#8230;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jbo5112</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-1417</link>
		<dc:creator>jbo5112</dc:creator>
		<pubDate>Wed, 15 Aug 2007 17:38:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-1417</guid>
		<description>Sorry to dig up an old discussion, but this method is too cool!  Of course you can skip the typedefs and name them manually (I'm just doing it here so my example is generic enough, easy to follow, easy to change and actually works).  I can't tell you the hours I've wasted trying to get something like this to work, and please note the first data type in the pair has to be const.



using namespace std;

typedef string map_key_type;
typedef string map_value_type;

map my_map;

BOOST_FOREACH( pair &#38;data, my_map )
{
// do your work on each pair here...
}</description>
		<content:encoded><![CDATA[<p>Sorry to dig up an old discussion, but this method is too cool!  Of course you can skip the typedefs and name them manually (I&#8217;m just doing it here so my example is generic enough, easy to follow, easy to change and actually works).  I can&#8217;t tell you the hours I&#8217;ve wasted trying to get something like this to work, and please note the first data type in the pair has to be const.</p>
<p>using namespace std;</p>
<p>typedef string map_key_type;<br />
typedef string map_value_type;</p>
<p>map my_map;</p>
<p>BOOST_FOREACH( pair &amp;data, my_map )<br />
{<br />
// do your work on each pair here&#8230;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Howell</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-357</link>
		<dc:creator>Max Howell</dc:creator>
		<pubDate>Tue, 01 May 2007 17:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-357</guid>
		<description>I tend to just go for all in one lines nowadays, since screens got bigger it's acceptable IMO.

But then again I hate huge variable declarations as they clutter the code and make parsing the code less quick by eye. Hence I never use the STL if I'm writing a Qt app :)

In the above example I'd prolly use the two liner. But I find most people, including myself miss double definitions of variables in this form. Not the end of the world, but it can be frustrating when trying to locate a variable's type. And KDevelop still doesn't help with a tooltip there.</description>
		<content:encoded><![CDATA[<p>I tend to just go for all in one lines nowadays, since screens got bigger it&#8217;s acceptable IMO.</p>
<p>But then again I hate huge variable declarations as they clutter the code and make parsing the code less quick by eye. Hence I never use the STL if I&#8217;m writing a Qt app <img src='http://blog.froglogic.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In the above example I&#8217;d prolly use the two liner. But I find most people, including myself miss double definitions of variables in this form. Not the end of the world, but it can be frustrating when trying to locate a variable&#8217;s type. And KDevelop still doesn&#8217;t help with a tooltip there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Voegele</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-264</link>
		<dc:creator>Jason Voegele</dc:creator>
		<pubDate>Mon, 23 Apr 2007 19:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-264</guid>
		<description>You must be very careful with style #3.  If the loop body modifies the container it is possible that the iterator held in the end variable will have been invalidated and your program will likely crash.  It is best not to use this style unless it is guaranteed that the loop body will not invalidate the iterator, and profiling indicates that it is worth performing this optimization (it probably is not in most circumstances).

For this reason (among others) I prefer style #1, or using a standard algorithm if possible.</description>
		<content:encoded><![CDATA[<p>You must be very careful with style #3.  If the loop body modifies the container it is possible that the iterator held in the end variable will have been invalidated and your program will likely crash.  It is best not to use this style unless it is guaranteed that the loop body will not invalidate the iterator, and profiling indicates that it is worth performing this optimization (it probably is not in most circumstances).</p>
<p>For this reason (among others) I prefer style #1, or using a standard algorithm if possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victor T.</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-261</link>
		<dc:creator>Victor T.</dc:creator>
		<pubDate>Mon, 23 Apr 2007 16:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-261</guid>
		<description>In all proposals till now I'm missing the fact that "end" could be declared constant:

const map::const_iterator end = map.end();

I tend to agree with Scott Meyers that everything that might be declared constant also should be declared constant. It might even help some (not-too-bright) compilers to generate better code. And obviously it also catches possible coding errors, as for instance a (wrong) assignment to "end" later on in the source code.</description>
		<content:encoded><![CDATA[<p>In all proposals till now I&#8217;m missing the fact that &#8220;end&#8221; could be declared constant:</p>
<p>const map::const_iterator end = map.end();</p>
<p>I tend to agree with Scott Meyers that everything that might be declared constant also should be declared constant. It might even help some (not-too-bright) compilers to generate better code. And obviously it also catches possible coding errors, as for instance a (wrong) assignment to &#8220;end&#8221; later on in the source code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryan</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-247</link>
		<dc:creator>ryan</dc:creator>
		<pubDate>Sat, 21 Apr 2007 22:13:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-247</guid>
		<description>I prefer to put things in a transform, for_each, or something like that. THe ugly is that the function has to be declared outside. C++ could really use 1) lambda expressions and 2) inline function declarations. Functional programming techniques rule. And no, boost::lambda and FC++ do not suffice.</description>
		<content:encoded><![CDATA[<p>I prefer to put things in a transform, for_each, or something like that. THe ugly is that the function has to be declared outside. C++ could really use 1) lambda expressions and 2) inline function declarations. Functional programming techniques rule. And no, boost::lambda and FC++ do not suffice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-240</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sat, 21 Apr 2007 09:40:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-240</guid>
		<description>BOOST_FOREACH( std::map::value_type i, myMap  ) {

}</description>
		<content:encoded><![CDATA[<p>BOOST_FOREACH( std::map::value_type i, myMap  ) {</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Herbert Graeber</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-237</link>
		<dc:creator>Herbert Graeber</dc:creator>
		<pubDate>Fri, 20 Apr 2007 22:34:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-237</guid>
		<description>Who says ther are no line breaks allowed inside the head of the for?
So, what about

for (
    map::const_iterator it = map.begin();
    it != map.end(); ++it 
) {
    ...
}</description>
		<content:encoded><![CDATA[<p>Who says ther are no line breaks allowed inside the head of the for?<br />
So, what about</p>
<p>for (<br />
    map::const_iterator it = map.begin();<br />
    it != map.end(); ++it<br />
) {<br />
    &#8230;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Esben Mose Hansen</title>
		<link>http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-235</link>
		<dc:creator>Esben Mose Hansen</dc:creator>
		<pubDate>Fri, 20 Apr 2007 20:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.froglogic.com/2007/04/the-one-true-iterator-declaration/#comment-235</guid>
		<description>for_each, tranform, accumulate and copy + boost::lambda handles a lot of the common cases (and would probably handle more for me if I could wrap my head around them)

I do sort of like the style that declares the end part in the first part of the for look. Never thought about that.

Am I the only one who suspects that I have a harder time with the captchas than a good OCR program would? ;)</description>
		<content:encoded><![CDATA[<p>for_each, tranform, accumulate and copy + boost::lambda handles a lot of the common cases (and would probably handle more for me if I could wrap my head around them)</p>
<p>I do sort of like the style that declares the end part in the first part of the for look. Never thought about that.</p>
<p>Am I the only one who suspects that I have a harder time with the captchas than a good OCR program would? <img src='http://blog.froglogic.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
