<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Why do cin and cout have conversion to a void* and not bool?</title>
	<atom:link href="http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/feed/" rel="self" type="application/rss+xml" />
	<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/</link>
	<description>Technical &#38; low level</description>
	<lastBuildDate>Mon, 30 Apr 2012 17:39:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: rmn</title>
		<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/#comment-90</link>
		<dc:creator>rmn</dc:creator>
		<pubDate>Sat, 24 Apr 2010 07:58:40 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=348#comment-90</guid>
		<description>I took the liberty to merge some of your replies, hope you don&#039;t mind. Indeed, adding an EDIT button would be just wonderful.. Unfortunately, I am not sure if there&#039;s such an option here (at least I was not able to find one).

Much thought has been put in the STL, and there is much to be learned from its design, functionality, and implementation. The point you brought up is another valid example. Thanks.</description>
		<content:encoded><![CDATA[<p>I took the liberty to merge some of your replies, hope you don&#8217;t mind. Indeed, adding an EDIT button would be just wonderful.. Unfortunately, I am not sure if there&#8217;s such an option here (at least I was not able to find one).</p>
<p>Much thought has been put in the STL, and there is much to be learned from its design, functionality, and implementation. The point you brought up is another valid example. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/#comment-89</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Fri, 16 Apr 2010 17:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=348#comment-89</guid>
		<description>if you would use such an imaginary frontAndPop() operation then the following code will be exception-unsafe:
[sourcecode language=&quot;cpp&quot;]string st(vec.frontAndPop()); // if frontAndPop() throws you lost your element(not consistent).[/sourcecode]

if the copy construction of string fails then you lost the element you&#039;ve just popped. if frontAndPop throws it&#039;s still ok.</description>
		<content:encoded><![CDATA[<p>if you would use such an imaginary frontAndPop() operation then the following code will be exception-unsafe:</p>
<pre class="brush: cpp; title: ; notranslate">string st(vec.frontAndPop()); // if frontAndPop() throws you lost your element(not consistent).</pre>
<p>if the copy construction of string fails then you lost the element you&#8217;ve just popped. if frontAndPop throws it&#8217;s still ok.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/#comment-88</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Fri, 16 Apr 2010 16:28:52 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=348#comment-88</guid>
		<description>By the way, regarding the sophistication of the STL developers. there is also another thing I found interesting about STL is that there is a seperation between a pop operation and a front/back operation on a STL container, and why there isn&#039;t such an operation frontAndPop for example? for me it sounds very convenient to use rather then first to use front and then pop. but actually there is a reason about it, it is because by seperating front and pop operation you actually can cope with cases where there is an exception, and make your code more exception safe(to continue to be in a consistent state), for example:
[sourcecode language=&quot;cpp&quot;]
int x = vec.back();
//.. some code here..(may throw) if it throws you don&#039;t lose the vector&#039;s last element! 
vec.pop_back();
[/sourcecode] </description>
		<content:encoded><![CDATA[<p>By the way, regarding the sophistication of the STL developers. there is also another thing I found interesting about STL is that there is a seperation between a pop operation and a front/back operation on a STL container, and why there isn&#8217;t such an operation frontAndPop for example? for me it sounds very convenient to use rather then first to use front and then pop. but actually there is a reason about it, it is because by seperating front and pop operation you actually can cope with cases where there is an exception, and make your code more exception safe(to continue to be in a consistent state), for example:</p>
<pre class="brush: cpp; title: ; notranslate">
int x = vec.back();
//.. some code here..(may throw) if it throws you don't lose the vector's last element!
vec.pop_back();
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/#comment-87</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Fri, 16 Apr 2010 16:00:36 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=348#comment-87</guid>
		<description>No question, you undertood me correctly, and actually I was mistaken about the signs and didn&#039;t notice that you used the opposite sign( i mean &gt;&gt; instead of &lt;&lt;).
It&#039;s ok now.
You are pretty skilled c++ programmer, your blog is great and I love your posts please keep posting, may be you can talk about the next revision of c++? I have found cool things there in particular literal overloading is pretty nice and nifty.</description>
		<content:encoded><![CDATA[<p>No question, you undertood me correctly, and actually I was mistaken about the signs and didn&#8217;t notice that you used the opposite sign( i mean &gt;&gt; instead of &lt;&lt;).<br />
It&#039;s ok now.<br />
You are pretty skilled c++ programmer, your blog is great and I love your posts please keep posting, may be you can talk about the next revision of c++? I have found cool things there in particular literal overloading is pretty nice and nifty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rmn</title>
		<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/#comment-86</link>
		<dc:creator>rmn</dc:creator>
		<pubDate>Fri, 16 Apr 2010 15:19:05 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=348#comment-86</guid>
		<description>I am not sure if I understand your question, but

There is nothing wrong with using [sourcecode]cout &lt;&lt; num[/sourcecode] or [sourcecode]cin &gt;&gt; num[/sourcecode]
The problem at hand is that using [sourcecode]cout &gt;&gt; num[/sourcecode] makes no sense, and we would like the compiler to generate an error in that case (since there&#039;s no overload for operator&gt;&gt;(ostream&amp;, int)).

In your question you are making a reference to ostream and operator&lt;&lt;, but then you ask about cin (which is an istream, not an ostream). Since there&#039;s no proper operator overload for that, a conversion should be attempted. Such a conversion should fail for the reasons listed above.

Please let me know if you still have questions, I&#039;ll be more than happy to help. Thanks for the interest.</description>
		<content:encoded><![CDATA[<p>I am not sure if I understand your question, but</p>
<p>There is nothing wrong with using
<pre class="brush: plain; title: ; notranslate">cout &lt;&lt; num</pre>
<p> or
<pre class="brush: plain; title: ; notranslate">cin &gt;&gt; num</pre>
<p>The problem at hand is that using
<pre class="brush: plain; title: ; notranslate">cout &gt;&gt; num</pre>
<p> makes no sense, and we would like the compiler to generate an error in that case (since there&#8217;s no overload for operator&gt;&gt;(ostream&amp;, int)).</p>
<p>In your question you are making a reference to ostream and operator&lt;&lt;, but then you ask about cin (which is an istream, not an ostream). Since there&#8217;s no proper operator overload for that, a conversion should be attempted. Such a conversion should fail for the reasons listed above.</p>
<p>Please let me know if you still have questions, I&#8217;ll be more than happy to help. Thanks for the interest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/#comment-85</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Fri, 16 Apr 2010 13:59:02 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=348#comment-85</guid>
		<description>But in the std namespace there is an overload of the operator&lt;&lt;(ostream&amp; os, int) why would the compiler choose to convert cin to bool rather then calling operator&lt;&lt;(..) with the given paramters?
please answer this one.</description>
		<content:encoded><![CDATA[<p>But in the std namespace there is an overload of the operator&lt;&lt;(ostream&amp; os, int) why would the compiler choose to convert cin to bool rather then calling operator&lt;&lt;(..) with the given paramters?<br />
please answer this one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://efesx.com/2009/10/11/why-do-cin-and-cout-have-conversion-to-void-and-not-bool/#comment-84</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Wed, 14 Oct 2009 21:18:40 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=348#comment-84</guid>
		<description>hey!
It was very interesting!
Thank&#039;s for the info!
(I love the way you&#039;ve written, it was fascinating!)</description>
		<content:encoded><![CDATA[<p>hey!<br />
It was very interesting!<br />
Thank&#8217;s for the info!<br />
(I love the way you&#8217;ve written, it was fascinating!)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

