<?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: Strong Optionals	</title>
	<atom:link href="https://www.fluentcpp.com/2018/01/16/strong-optionals/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/01/16/strong-optionals/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Mon, 22 Jan 2018 14:45: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: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-769</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Mon, 22 Jan 2018 14:45:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2583#comment-769</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-756&quot;&gt;Arash Kashani&lt;/a&gt;.

There is, and I plan to write about that :) In the meantime, maybe you&#039;ll be interested in having a look at &lt;a href=&quot;https://theboostcpplibraries.com/boost.parameter&quot; rel=&quot;nofollow&quot;&gt;Boost.Parameter&lt;/a&gt;, that does it and much more, but at the cost of impacting the function prototype.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-756">Arash Kashani</a>.</p>
<p>There is, and I plan to write about that 🙂 In the meantime, maybe you&#8217;ll be interested in having a look at <a href="https://theboostcpplibraries.com/boost.parameter" rel="nofollow">Boost.Parameter</a>, that does it and much more, but at the cost of impacting the function prototype.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-768</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Mon, 22 Jan 2018 14:43:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2583#comment-768</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-760&quot;&gt;sehe&lt;/a&gt;.

Ok so passing the semantics of a default consructed-optional through the strong type construction. Thanks for sharing this idea, sehe.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-760">sehe</a>.</p>
<p>Ok so passing the semantics of a default consructed-optional through the strong type construction. Thanks for sharing this idea, sehe.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sehe		</title>
		<link>https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-760</link>

		<dc:creator><![CDATA[sehe]]></dc:creator>
		<pubDate>Wed, 17 Jan 2018 10:42:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2583#comment-760</guid>

					<description><![CDATA[Seems to me naming/tagging should be orthogonal to optionality.

(&lt;i&gt;In fact, using optional in the interface presents issues (you can&#039;t ever pass temporary values by const reference because the optional doesn&#039;t afford references -- with good reason, but still). I&#039;d probably avoid optional here.&lt;/i&gt;)

&lt;pre&gt;&lt;code&gt;
namespace mylibrary {
    // expose &quot;Niebler&quot; functors for callers
    using tagging::tag;
    inline constexpr auto firstname = tag;
    inline constexpr auto lastname  = tag;

    using opt_str = std::optional;
    using tagging::tagged;

    void findEmployees(tagged firstname, tagged lastname) {
        auto sep = [first=true]() mutable { return first? (first = false, &quot;&quot;) : &quot;, &quot;; };

        std::cout &#060;&#060; &#034;findEmployees(&#034;;
        if (firstname) std::cout &#060;&#060; sep() &#060;&#060; &#034;firstname:&#034; &#060;&#060; std::quoted(*firstname);
        if (lastname)  std::cout &#060;&#060; sep() &#060;&#060; &#034;lastname:&#034; &#060;&#060; std::quoted(*lastname);
        std::cout &#060;&#060; &#034;)n&#034;;
    }

    template 
        void genericQuery(tagged firstname, tagged lastname) {
            std::cout &#060;&#060; &#034;genericQuery(&#034; &#060;&#060; firstname &#060;&#060; &#034;, &#034; &#060;&#060; lastname &#060;&#060; &#034;)n&#034;;
        }
}
&lt;/code&gt;&lt;/pre&gt;

See a full PoC: http://coliru.stacked-crooked.com/a/0a8b618f7670cda7]]></description>
			<content:encoded><![CDATA[<p>Seems to me naming/tagging should be orthogonal to optionality.</p>
<p>(<i>In fact, using optional in the interface presents issues (you can&#8217;t ever pass temporary values by const reference because the optional doesn&#8217;t afford references &#8212; with good reason, but still). I&#8217;d probably avoid optional here.</i>)</p>
<pre><code>
namespace mylibrary {
    // expose "Niebler" functors for callers
    using tagging::tag;
    inline constexpr auto firstname = tag;
    inline constexpr auto lastname  = tag;

    using opt_str = std::optional;
    using tagging::tagged;

    void findEmployees(tagged firstname, tagged lastname) {
        auto sep = [first=true]() mutable { return first? (first = false, "") : ", "; };

        std::cout &lt;&lt; &quot;findEmployees(&quot;;
        if (firstname) std::cout &lt;&lt; sep() &lt;&lt; &quot;firstname:&quot; &lt;&lt; std::quoted(*firstname);
        if (lastname)  std::cout &lt;&lt; sep() &lt;&lt; &quot;lastname:&quot; &lt;&lt; std::quoted(*lastname);
        std::cout &lt;&lt; &quot;)n&quot;;
    }

    template 
        void genericQuery(tagged firstname, tagged lastname) {
            std::cout &lt;&lt; &quot;genericQuery(&quot; &lt;&lt; firstname &lt;&lt; &quot;, &quot; &lt;&lt; lastname &lt;&lt; &quot;)n&quot;;
        }
}
</code></pre>
<p>See a full PoC: <a href="http://coliru.stacked-crooked.com/a/0a8b618f7670cda7" rel="nofollow ugc">http://coliru.stacked-crooked.com/a/0a8b618f7670cda7</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arne Hildingsson		</title>
		<link>https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-759</link>

		<dc:creator><![CDATA[Arne Hildingsson]]></dc:creator>
		<pubDate>Tue, 16 Jan 2018 19:33:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2583#comment-759</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-756&quot;&gt;Arash Kashani&lt;/a&gt;.

Perhaps something like this:

enum class QueryType
{
	FirstName,
	LastName
};

struct QueryData
{
	QueryType type;
	std::string data;
};

std::vector findEmployees(std::vector queryData);

At call site:

findEmployees({ { QueryType::FirstName,&quot;John&quot; } });
findEmployees({ { QueryType::FirstName,&quot;John&quot; },
                           { QueryType::LastName,&quot;Doe&quot; } });
findEmployees({ { QueryType::LastName,&quot;Doe&quot; },
                           { QueryType::FirstName,&quot;John&quot; } });

It is ugly with all the braces, but ...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-756">Arash Kashani</a>.</p>
<p>Perhaps something like this:</p>
<p>enum class QueryType<br />
{<br />
	FirstName,<br />
	LastName<br />
};</p>
<p>struct QueryData<br />
{<br />
	QueryType type;<br />
	std::string data;<br />
};</p>
<p>std::vector findEmployees(std::vector queryData);</p>
<p>At call site:</p>
<p>findEmployees({ { QueryType::FirstName,&#8221;John&#8221; } });<br />
findEmployees({ { QueryType::FirstName,&#8221;John&#8221; },<br />
                           { QueryType::LastName,&#8221;Doe&#8221; } });<br />
findEmployees({ { QueryType::LastName,&#8221;Doe&#8221; },<br />
                           { QueryType::FirstName,&#8221;John&#8221; } });</p>
<p>It is ugly with all the braces, but &#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arash Kashani		</title>
		<link>https://www.fluentcpp.com/2018/01/16/strong-optionals/#comment-756</link>

		<dc:creator><![CDATA[Arash Kashani]]></dc:creator>
		<pubDate>Tue, 16 Jan 2018 14:04:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2583#comment-756</guid>

					<description><![CDATA[interesting article. I am always wonder if there is a way to mimic python-style keyword arguments in c++ at call site. something like:

findEmployee (firstname=&quot;John&quot;,lastname=&quot;Doe&quot;)

or 

findEmployee (lastname=&quot;Doe&quot; , firstname=&quot;John&quot;)

do you know a solution?]]></description>
			<content:encoded><![CDATA[<p>interesting article. I am always wonder if there is a way to mimic python-style keyword arguments in c++ at call site. something like:</p>
<p>findEmployee (firstname=&#8221;John&#8221;,lastname=&#8221;Doe&#8221;)</p>
<p>or </p>
<p>findEmployee (lastname=&#8221;Doe&#8221; , firstname=&#8221;John&#8221;)</p>
<p>do you know a solution?</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
