<?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: Defaulted: A Helper to Work Around the Constraints of C++ Default Parameters	</title>
	<atom:link href="https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Wed, 22 Aug 2018 10:37:21 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1227</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 17 Aug 2018 15:20:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2178#comment-1227</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1218&quot;&gt;Vincent Zalzal&lt;/a&gt;.

Interesting solution indeed, thanks for sharing!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1218">Vincent Zalzal</a>.</p>
<p>Interesting solution indeed, thanks for sharing!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Kuba Ober		</title>
		<link>https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1224</link>

		<dc:creator><![CDATA[Kuba Ober]]></dc:creator>
		<pubDate>Wed, 15 Aug 2018 22:38:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2178#comment-1224</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1220&quot;&gt;Kaushik Basu&lt;/a&gt;.

That&#039;s what source code rewriting is for. Take Eli Benderski&#039;s tooling_sample.cpp, have it detect the calls and rewrite them the way you want them to be. Boom and done.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1220">Kaushik Basu</a>.</p>
<p>That&#8217;s what source code rewriting is for. Take Eli Benderski&#8217;s tooling_sample.cpp, have it detect the calls and rewrite them the way you want them to be. Boom and done.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: jft		</title>
		<link>https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1221</link>

		<dc:creator><![CDATA[jft]]></dc:creator>
		<pubDate>Wed, 15 Aug 2018 10:10:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2178#comment-1221</guid>

					<description><![CDATA[As named parameter passing has been rejected for good reasons, why not simply be able to leave out any required default argument?


If we have
void f(int x, int y = 42, int z)
...


then why not simply
f(1, , 3);


to imply that the missing argument should take the default one? If no default one specified, then report an error.]]></description>
			<content:encoded><![CDATA[<p>As named parameter passing has been rejected for good reasons, why not simply be able to leave out any required default argument?</p>
<p>If we have<br />
void f(int x, int y = 42, int z)<br />
&#8230;</p>
<p>then why not simply<br />
f(1, , 3);</p>
<p>to imply that the missing argument should take the default one? If no default one specified, then report an error.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Kaushik Basu		</title>
		<link>https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1220</link>

		<dc:creator><![CDATA[Kaushik Basu]]></dc:creator>
		<pubDate>Tue, 14 Aug 2018 11:54:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2178#comment-1220</guid>

					<description><![CDATA[One drawback I see is if I have to change an existing function which is already called from multiple places to have an additional parameter for a new requirement, then I have to change all existing calls to use the &quot;defaultValue&quot;.
For large code bases, this can be a problem.]]></description>
			<content:encoded><![CDATA[<p>One drawback I see is if I have to change an existing function which is already called from multiple places to have an additional parameter for a new requirement, then I have to change all existing calls to use the &#8220;defaultValue&#8221;.<br />
For large code bases, this can be a problem.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Vincent Zalzal		</title>
		<link>https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1218</link>

		<dc:creator><![CDATA[Vincent Zalzal]]></dc:creator>
		<pubDate>Tue, 14 Aug 2018 02:58:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2178#comment-1218</guid>

					<description><![CDATA[There is another alternative to handle multiple default parameters: not encoding the default value in the Defaulted type, and letting the callee handle the default value. In that case, std::optional can be used instead of Defaulted.

&lt;pre&gt;&lt;code class=&quot;C++&quot;&gt;
void g(int x, std::optional y /* = 45.6 */, int z)
{
    std::cout &#060;&#060; &#034;x = &#034; &#060;&#060; x &#060;&#060; &#039;n&#039;
              &#060;&#060; &#034;y = &#034; &#060;&#060; y.value_or(45.6) &#060;&#060; &#039;n&#039;
              &#060;&#060; &#034;z = &#034; &#060;&#060; z &#060;&#060; &#039;n&#039;;
}

g(0, std::nullopt, 1);
g(0, {}, 1);
&lt;/code&gt;&lt;/pre&gt;

It has the advantage of being able to support doubles or aggregates that a template parameter can&#039;t. It has the drawback that the default value is not documented in the interface anymore, which I suspect you won&#039;t like much. Also, optional references are not supported (yet?), so it is not a good option for slow-to-copy types.]]></description>
			<content:encoded><![CDATA[<p>There is another alternative to handle multiple default parameters: not encoding the default value in the Defaulted type, and letting the callee handle the default value. In that case, std::optional can be used instead of Defaulted.</p>
<pre><code class="C++">
void g(int x, std::optional y /* = 45.6 */, int z)
{
    std::cout &lt;&lt; &quot;x = &quot; &lt;&lt; x &lt;&lt; &#039;n&#039;
              &lt;&lt; &quot;y = &quot; &lt;&lt; y.value_or(45.6) &lt;&lt; &#039;n&#039;
              &lt;&lt; &quot;z = &quot; &lt;&lt; z &lt;&lt; &#039;n&#039;;
}

g(0, std::nullopt, 1);
g(0, {}, 1);
</code></pre>
<p>It has the advantage of being able to support doubles or aggregates that a template parameter can&#8217;t. It has the drawback that the default value is not documented in the interface anymore, which I suspect you won&#8217;t like much. Also, optional references are not supported (yet?), so it is not a good option for slow-to-copy types.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Vincent Zalzal		</title>
		<link>https://www.fluentcpp.com/2018/08/14/defaulted-helper-work-around-constraints-default-parameters/#comment-1217</link>

		<dc:creator><![CDATA[Vincent Zalzal]]></dc:creator>
		<pubDate>Tue, 14 Aug 2018 02:37:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2178#comment-1217</guid>

					<description><![CDATA[A neat trick that will probably become available in C++2a is to use designated initializers to handle named parameters with default values. This has been featured in a recent video of Jason Turner : https://youtu.be/44rs_hX1dxE]]></description>
			<content:encoded><![CDATA[<p>A neat trick that will probably become available in C++2a is to use designated initializers to handle named parameters with default values. This has been featured in a recent video of Jason Turner : <a href="https://youtu.be/44rs_hX1dxE" rel="nofollow ugc">https://youtu.be/44rs_hX1dxE</a></p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
