<?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: Restricting an interface in C++	</title>
	<atom:link href="https://www.fluentcpp.com/2017/04/07/restricting-interface/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2017/04/07/restricting-interface/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Thu, 25 May 2017 21:28:15 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.5</generator>
	<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-215</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Thu, 20 Apr 2017 13:33:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=594#comment-215</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-214&quot;&gt;Jonathan O&#039;Connor&lt;/a&gt;.

Thanks Jonathan for this interesting point. I did a little research and experimentation to be able to provide an answer.

It turns out that defining a unique_ptr member doesn&#039;t require in itself the definition of the class. The definition is needed for instantiating the destructor of unique_ptr. The rationale behind this is that deleting a pointer to an incomplete type (declared only) leads to undefined behaviour, so the unique_ptr prevents this from compiling altogether.

Pushing a unique_ptr on the stack, like on the example you provided, calls the destructor of unique_ptr, so needs the definition. However, using it in a pimpl doesn&#039;t need the definition visible from the pimpl declaration, as long as the pimpl destructor is not implemented along with the declaration in the header.

Very interesting point! :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-214">Jonathan O&#8217;Connor</a>.</p>
<p>Thanks Jonathan for this interesting point. I did a little research and experimentation to be able to provide an answer.</p>
<p>It turns out that defining a unique_ptr member doesn&#8217;t require in itself the definition of the class. The definition is needed for instantiating the destructor of unique_ptr. The rationale behind this is that deleting a pointer to an incomplete type (declared only) leads to undefined behaviour, so the unique_ptr prevents this from compiling altogether.</p>
<p>Pushing a unique_ptr on the stack, like on the example you provided, calls the destructor of unique_ptr, so needs the definition. However, using it in a pimpl doesn&#8217;t need the definition visible from the pimpl declaration, as long as the pimpl destructor is not implemented along with the declaration in the header.</p>
<p>Very interesting point! 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan O'Connor		</title>
		<link>https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-214</link>

		<dc:creator><![CDATA[Jonathan O'Connor]]></dc:creator>
		<pubDate>Wed, 19 Apr 2017 17:02:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=594#comment-214</guid>

					<description><![CDATA[In keeping with the article, I thought it was appropriate for me to comment!

I first came across the pimpl pattern in 1988. My boss, the late John Carolan, called it the cheshire cat pattern, because the pointer was like the smile of the Lewis Carroll&#039;s cat in Alice in Wonderland. We used the pattern extensively for a GUI framework, called CommonView. I don&#039;t know if he invented it, but I suspect it was already known.

Recently, I have wondered if this technique works with std::unique_ptr, but I believe the implementation of std::unique_ptr prevents a user creating an instance of unique_ptr without knowing the full structure of Foo.

I got errors compiling the following: https://godbolt.org/g/WM8xqs]]></description>
			<content:encoded><![CDATA[<p>In keeping with the article, I thought it was appropriate for me to comment!</p>
<p>I first came across the pimpl pattern in 1988. My boss, the late John Carolan, called it the cheshire cat pattern, because the pointer was like the smile of the Lewis Carroll&#8217;s cat in Alice in Wonderland. We used the pattern extensively for a GUI framework, called CommonView. I don&#8217;t know if he invented it, but I suspect it was already known.</p>
<p>Recently, I have wondered if this technique works with std::unique_ptr, but I believe the implementation of std::unique_ptr prevents a user creating an instance of unique_ptr without knowing the full structure of Foo.</p>
<p>I got errors compiling the following: <a href="https://godbolt.org/g/WM8xqs" rel="nofollow ugc">https://godbolt.org/g/WM8xqs</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-197</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Sun, 09 Apr 2017 15:46:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=594#comment-197</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-195&quot;&gt;robin&lt;/a&gt;.

Cheers Robin, glad that you appreciate it.
This is a very good question. In fact, I keep doubles for the members because the member themselves already have names, contrary to parameters passed to an interface at call site. But I recognize this is subject to debate! :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-195">robin</a>.</p>
<p>Cheers Robin, glad that you appreciate it.<br />
This is a very good question. In fact, I keep doubles for the members because the member themselves already have names, contrary to parameters passed to an interface at call site. But I recognize this is subject to debate! 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: robin		</title>
		<link>https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-195</link>

		<dc:creator><![CDATA[robin]]></dc:creator>
		<pubDate>Fri, 07 Apr 2017 14:59:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=594#comment-195</guid>

					<description><![CDATA[&#062; Wonder how to easily define explicit types such as Weight and Height? These are called strong types, head over to this post if you want to know more about this
This is kinda funny to see this note, and that you still used double instead of Weight and Height for the type of your members!. Great blog btw.]]></description>
			<content:encoded><![CDATA[<p>&gt; Wonder how to easily define explicit types such as Weight and Height? These are called strong types, head over to this post if you want to know more about this<br />
This is kinda funny to see this note, and that you still used double instead of Weight and Height for the type of your members!. Great blog btw.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-193</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 07 Apr 2017 08:24:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=594#comment-193</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-192&quot;&gt;Michal Barton&lt;/a&gt;.

Good point Michal. Well here the purpose was to avoid dynamic polymorphism in order to manipulate objects with value semantics, and also because there aren&#039;t several possible classes hiding behind one interface in the case here. But your point is totally valid, maybe I should have mentioned it in the exploration of possibilities.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-192">Michal Barton</a>.</p>
<p>Good point Michal. Well here the purpose was to avoid dynamic polymorphism in order to manipulate objects with value semantics, and also because there aren&#8217;t several possible classes hiding behind one interface in the case here. But your point is totally valid, maybe I should have mentioned it in the exploration of possibilities.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michal Barton		</title>
		<link>https://www.fluentcpp.com/2017/04/07/restricting-interface/#comment-192</link>

		<dc:creator><![CDATA[Michal Barton]]></dc:creator>
		<pubDate>Fri, 07 Apr 2017 07:32:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=594#comment-192</guid>

					<description><![CDATA[Why not to just create IDrawable interface for it?]]></description>
			<content:encoded><![CDATA[<p>Why not to just create IDrawable interface for it?</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
