<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	
	>
<channel>
	<title>
	Comments on: The Incredible Const Reference That Isn&#8217;t Const	</title>
	<atom:link href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Sat, 17 Nov 2018 23:44:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: Oleg		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1473</link>

		<dc:creator><![CDATA[Oleg]]></dc:creator>
		<pubDate>Sat, 17 Nov 2018 23:44:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1473</guid>

					<description><![CDATA[Wasn&#039;t it just a compiler bug? If you try it now you will get a compilation error...]]></description>
			<content:encoded><![CDATA[<p>Wasn&#8217;t it just a compiler bug? If you try it now you will get a compilation error&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David Freese		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1146</link>

		<dc:creator><![CDATA[David Freese]]></dc:creator>
		<pubDate>Fri, 20 Jul 2018 23:37:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1146</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1139&quot;&gt;Jonathan Boccara&lt;/a&gt;.

Thanks for the follow up!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1139">Jonathan Boccara</a>.</p>
<p>Thanks for the follow up!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Andrea Griffini		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1145</link>

		<dc:creator><![CDATA[Andrea Griffini]]></dc:creator>
		<pubDate>Fri, 20 Jul 2018 14:08:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1145</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1140&quot;&gt;Christian Göhring&lt;/a&gt;.

You are wrong but this is not probably the best place for such a discussion. Some of the issues in the (ab)use of const reference in C++ can be seen here:

https://stackoverflow.com/a/4705871/320726]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1140">Christian Göhring</a>.</p>
<p>You are wrong but this is not probably the best place for such a discussion. Some of the issues in the (ab)use of const reference in C++ can be seen here:</p>
<p><a href="https://stackoverflow.com/a/4705871/320726" rel="nofollow ugc">https://stackoverflow.com/a/4705871/320726</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Christian Göhring		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1140</link>

		<dc:creator><![CDATA[Christian Göhring]]></dc:creator>
		<pubDate>Fri, 20 Jul 2018 12:08:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1140</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1137&quot;&gt;Andrea Griffini&lt;/a&gt;.

Const correctness is obviously very useful when your compiler stops you from modifying a const object. Additionally its impact reaches further than just compiler errors (binary size, memory usage, etc). The biggest obstacle for const-correctness is developer laziness.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1137">Andrea Griffini</a>.</p>
<p>Const correctness is obviously very useful when your compiler stops you from modifying a const object. Additionally its impact reaches further than just compiler errors (binary size, memory usage, etc). The biggest obstacle for const-correctness is developer laziness.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1139</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 20 Jul 2018 11:04:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1139</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1134&quot;&gt;David Freese&lt;/a&gt;.

There may be a case where you do want to wrap a reference: to pass strong types by references. Here is &lt;a href=&quot;https://www.fluentcpp.com/2017/03/06/passing-strong-types-reference-revisited/&quot;&gt;an article that presents that need&lt;/a&gt; if you&#039;d like to have a look.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1134">David Freese</a>.</p>
<p>There may be a case where you do want to wrap a reference: to pass strong types by references. Here is <a href="https://www.fluentcpp.com/2017/03/06/passing-strong-types-reference-revisited/">an article that presents that need</a> if you&#8217;d like to have a look.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Andrea Griffini		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1137</link>

		<dc:creator><![CDATA[Andrea Griffini]]></dc:creator>
		<pubDate>Fri, 20 Jul 2018 05:54:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1137</guid>

					<description><![CDATA[In the second example you&#039;re wrapping an `int&#038;` ...more specifically a non-const one. Why do you find &quot;strange&quot; that when you get back the reference from `get()` you can use it to write? You are not mutating the wrapped object (a reference) but the referenced value. If you wrap a `const int &#038;` instead then you get a compile error.

C++ const correctness idea is in my opinion indeed badly broken and, more importantly, not so useful and way overrated in the C++ community. But in this very specific case I&#039;d say that it behaves &quot;logically&quot; and &quot;intuitively&quot; (up to the limits these words can have in a mess like C++).]]></description>
			<content:encoded><![CDATA[<p>In the second example you&#8217;re wrapping an `int&amp;` &#8230;more specifically a non-const one. Why do you find &#8220;strange&#8221; that when you get back the reference from `get()` you can use it to write? You are not mutating the wrapped object (a reference) but the referenced value. If you wrap a `const int &amp;` instead then you get a compile error.</p>
<p>C++ const correctness idea is in my opinion indeed badly broken and, more importantly, not so useful and way overrated in the C++ community. But in this very specific case I&#8217;d say that it behaves &#8220;logically&#8221; and &#8220;intuitively&#8221; (up to the limits these words can have in a mess like C++).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jean-François Lévesque		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1136</link>

		<dc:creator><![CDATA[Jean-François Lévesque]]></dc:creator>
		<pubDate>Wed, 18 Jul 2018 20:44:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1136</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1134&quot;&gt;David Freese&lt;/a&gt;.

None that I can see.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1134">David Freese</a>.</p>
<p>None that I can see.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David Freese		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1134</link>

		<dc:creator><![CDATA[David Freese]]></dc:creator>
		<pubDate>Wed, 18 Jul 2018 18:46:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1134</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1108&quot;&gt;Jean-François Lévesque&lt;/a&gt;.

I&#039;m glad someone had pointed this out.  It seems the wrapper would never be intended to be used with a reference type, so just disallow it.  Am I missing a potential use case?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1108">Jean-François Lévesque</a>.</p>
<p>I&#8217;m glad someone had pointed this out.  It seems the wrapper would never be intended to be used with a reference type, so just disallow it.  Am I missing a potential use case?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arne Vogel		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1133</link>

		<dc:creator><![CDATA[Arne Vogel]]></dc:creator>
		<pubDate>Wed, 18 Jul 2018 16:58:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1133</guid>

					<description><![CDATA[Who doesn&#039;t love to read some arcane standardese? So, here it is:

    (6) If a typedef-name ([dcl.typedef], [temp.param]) or a decltype-specifier denotes a type TR that is a reference to a type T, an attempt to create the type “lvalue reference to cv TR” creates the type “lvalue reference to T”

See https://timsong-cpp.github.io/cppwp/n4659/dcl.ref

So we have:

T = int
TR = int &#038;
cv TR (here) = int &#038; const (NOT int const &#038; – a const reference to non-const, not a non-const reference to const, as you wrote)
created type = int &#038; (because the cv part is then conveniently dropped)

I think the rules were written in this way because they didn&#039;t want to suddenly allow references to references, but at the same time make argument forwarding (where this scenario would occur particularily often) behave much the same as if they were allowed. It&#039;s also consistent with the fact we can write through a int *const &#038; (a reference to a const pointer to int) by using the unary operator *, confusing as it is in this context.

You probably have noticed that I&#039;m really split here: It makes sense why they did that, but it&#039;s still very unexpected and could easily lead to some major bugs.]]></description>
			<content:encoded><![CDATA[<p>Who doesn&#8217;t love to read some arcane standardese? So, here it is:</p>
<p>    (6) If a typedef-name ([dcl.typedef], [temp.param]) or a decltype-specifier denotes a type TR that is a reference to a type T, an attempt to create the type “lvalue reference to cv TR” creates the type “lvalue reference to T”</p>
<p>See <a href="https://timsong-cpp.github.io/cppwp/n4659/dcl.ref" rel="nofollow ugc">https://timsong-cpp.github.io/cppwp/n4659/dcl.ref</a></p>
<p>So we have:</p>
<p>T = int<br />
TR = int &amp;<br />
cv TR (here) = int &amp; const (NOT int const &amp; – a const reference to non-const, not a non-const reference to const, as you wrote)<br />
created type = int &amp; (because the cv part is then conveniently dropped)</p>
<p>I think the rules were written in this way because they didn&#8217;t want to suddenly allow references to references, but at the same time make argument forwarding (where this scenario would occur particularily often) behave much the same as if they were allowed. It&#8217;s also consistent with the fact we can write through a int *const &amp; (a reference to a const pointer to int) by using the unary operator *, confusing as it is in this context.</p>
<p>You probably have noticed that I&#8217;m really split here: It makes sense why they did that, but it&#8217;s still very unexpected and could easily lead to some major bugs.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1132</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Wed, 18 Jul 2018 10:57:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=3825#comment-1132</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1129&quot;&gt;Edoardo Morandi&lt;/a&gt;.

Okay, thanks for sharing your experience Edoardo!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/07/13/the-incredible-const-reference-that-isnt-const/#comment-1129">Edoardo Morandi</a>.</p>
<p>Okay, thanks for sharing your experience Edoardo!</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
