<?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 for 抠腚爱揉曼</title>
	<atom:link href="http://a.vifix.us/blog/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://a.vifix.us/blog</link>
	<description>Coding Iron Man</description>
	<lastBuildDate>Mon, 09 Jan 2012 01:26:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>Comment on 虚跟模板可以兼得？！ by Jay</title>
		<link>http://a.vifix.us/blog/virtual-template-cpp#comment-1252</link>
		<dc:creator>Jay</dc:creator>
		<pubDate>Mon, 09 Jan 2012 01:26:20 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=193#comment-1252</guid>
		<description>目前我的案例的情况是：
1. 类C以及其各种子类是由模块A定义使用的。
2. 现在需要在模块B中将类C以及各种子类通过模块B特有的序列化器输出。
3. 模块A不能依赖模块B，但是模块B可以依赖模块A，因此不能修改模块A里面的类C以及其各种子类让其对模块B产生依赖。

因为在模块B里面接收到的已经只是类C的基类了，所以不能在模块B里面去展开模板类SerializableWrapper，同样因为上面的原因也不能在模块A里面去添加特有的模板实例化的代码。这个问题就很类似Abstract Factory，因为其在模块B里面已经是“动态”的类型检测了，相对Map映射来说，switch case还是要高效一些吧。</description>
		<content:encoded><![CDATA[<p>目前我的案例的情况是：<br />
1. 类C以及其各种子类是由模块A定义使用的。<br />
2. 现在需要在模块B中将类C以及各种子类通过模块B特有的序列化器输出。<br />
3. 模块A不能依赖模块B，但是模块B可以依赖模块A，因此不能修改模块A里面的类C以及其各种子类让其对模块B产生依赖。</p>
<p>因为在模块B里面接收到的已经只是类C的基类了，所以不能在模块B里面去展开模板类SerializableWrapper，同样因为上面的原因也不能在模块A里面去添加特有的模板实例化的代码。这个问题就很类似Abstract Factory，因为其在模块B里面已经是“动态”的类型检测了，相对Map映射来说，switch case还是要高效一些吧。</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 虚跟模板可以兼得？！ by FantasyDR</title>
		<link>http://a.vifix.us/blog/virtual-template-cpp#comment-1220</link>
		<dc:creator>FantasyDR</dc:creator>
		<pubDate>Wed, 28 Dec 2011 05:53:48 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=193#comment-1220</guid>
		<description>诡异啊，格式直接乱了。
template &lt;T&gt; class SerializableWrapper : public Serializable {... }</description>
		<content:encoded><![CDATA[<p>诡异啊，格式直接乱了。<br />
template &lt;T&gt; class SerializableWrapper : public Serializable {&#8230; }</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 虚跟模板可以兼得？！ by FantasyDR</title>
		<link>http://a.vifix.us/blog/virtual-template-cpp#comment-1219</link>
		<dc:creator>FantasyDR</dc:creator>
		<pubDate>Wed, 28 Dec 2011 05:52:29 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=193#comment-1219</guid>
		<description>感觉你这方向不对头，virtual+template了还要出switch case，这就是坏味道。核心矛盾有两个：
1、纯粹用虚，这要求所有被序列化的对象继承自同一个根，很多情况下满足不了。
2、纯粹用模板也不行，你已经说了。

为了避免switch case的写法，你可以用两层设计。首先Serialize接口还是virtual的。
class Serializable {public: virtual void Serialize(Serializer&amp; serializer) = 0; }

然后template继承自这个接口，省去一大部分代码重复书写：
template
class SerializableWrapper {
private:
 T&amp; _ref;
public:
 SerializableWrapper(T&amp; ref):_ref(ref){}
 virtual void Serialize(Serializer&amp; serializer) { _ref.Serialize(serializer); }
}

所有类型都可以这样搞。

如果有需要特别处理的，别犹豫，用模板特化。</description>
		<content:encoded><![CDATA[<p>感觉你这方向不对头，virtual+template了还要出switch case，这就是坏味道。核心矛盾有两个：<br />
1、纯粹用虚，这要求所有被序列化的对象继承自同一个根，很多情况下满足不了。<br />
2、纯粹用模板也不行，你已经说了。</p>
<p>为了避免switch case的写法，你可以用两层设计。首先Serialize接口还是virtual的。<br />
class Serializable {public: virtual void Serialize(Serializer&amp; serializer) = 0; }</p>
<p>然后template继承自这个接口，省去一大部分代码重复书写：<br />
template<br />
class SerializableWrapper {<br />
private:<br />
 T&amp; _ref;<br />
public:<br />
 SerializableWrapper(T&amp; ref):_ref(ref){}<br />
 virtual void Serialize(Serializer&amp; serializer) { _ref.Serialize(serializer); }<br />
}</p>
<p>所有类型都可以这样搞。</p>
<p>如果有需要特别处理的，别犹豫，用模板特化。</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 无聊转个笑话……[The Daily WTF]Got Time? by 关于脚本 &#171; 抠腚爱揉曼</title>
		<link>http://a.vifix.us/blog/%e6%97%a0%e8%81%8a%e8%bd%ac%e4%b8%aa%e7%ac%91%e8%af%9d-the-daily-wtf-got-time#comment-1090</link>
		<dc:creator>关于脚本 &#171; 抠腚爱揉曼</dc:creator>
		<pubDate>Tue, 15 Nov 2011 06:21:24 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=120#comment-1090</guid>
		<description>[...] 太硬的东西无论是开发者还是客户都所不愿意见到的，他们不希望自己买了一辆自行车，轮子只能转到100圈，除非他们都是2B。 [...]</description>
		<content:encoded><![CDATA[<p>[...] 太硬的东西无论是开发者还是客户都所不愿意见到的，他们不希望自己买了一辆自行车，轮子只能转到100圈，除非他们都是2B。 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 无聊转个笑话……[The Daily WTF]Got Time? by DianD</title>
		<link>http://a.vifix.us/blog/%e6%97%a0%e8%81%8a%e8%bd%ac%e4%b8%aa%e7%ac%91%e8%af%9d-the-daily-wtf-got-time#comment-1059</link>
		<dc:creator>DianD</dc:creator>
		<pubDate>Wed, 19 Oct 2011 01:41:58 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=120#comment-1059</guid>
		<description>哈哈哈哈</description>
		<content:encoded><![CDATA[<p>哈哈哈哈</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 最近败了个台式机以及360就是贱啊 by Marlon Cahue</title>
		<link>http://a.vifix.us/blog/%e6%9c%80%e8%bf%91%e8%b4%a5%e4%ba%86%e4%b8%aa%e5%8f%b0%e5%bc%8f%e6%9c%ba%e4%bb%a5%e5%8f%8a360%e5%b0%b1%e6%98%af%e8%b4%b1%e5%95%8a#comment-1032</link>
		<dc:creator>Marlon Cahue</dc:creator>
		<pubDate>Thu, 13 Oct 2011 18:53:54 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=151#comment-1032</guid>
		<description>hen xi huan ni xie de wen zhang</description>
		<content:encoded><![CDATA[<p>hen xi huan ni xie de wen zhang</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on About by draem0507</title>
		<link>http://a.vifix.us/blog/about#comment-1027</link>
		<dc:creator>draem0507</dc:creator>
		<pubDate>Mon, 10 Oct 2011 01:58:51 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?page_id=2#comment-1027</guid>
		<description>抠腚男--&gt;java 申请加入blog :evil:</description>
		<content:encoded><![CDATA[<p>抠腚男&#8211;&gt;java 申请加入blog <img src='http://a.vifix.us/blog/wp-includes/images/smilies/icon_evil.gif' alt=':evil:' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 资料收集[置顶] by welpher.yu</title>
		<link>http://a.vifix.us/blog/pro-git#comment-983</link>
		<dc:creator>welpher.yu</dc:creator>
		<pubDate>Tue, 27 Sep 2011 03:46:38 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=167#comment-983</guid>
		<description>更新了</description>
		<content:encoded><![CDATA[<p>更新了</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 资料收集[置顶] by Sheldon</title>
		<link>http://a.vifix.us/blog/pro-git#comment-981</link>
		<dc:creator>Sheldon</dc:creator>
		<pubDate>Mon, 26 Sep 2011 03:27:13 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=167#comment-981</guid>
		<description>有订阅这个功能好不好。</description>
		<content:encoded><![CDATA[<p>有订阅这个功能好不好。</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 来scala下Scala by welpher.yu</title>
		<link>http://a.vifix.us/blog/%e6%9d%a5scala%e4%b8%8bscala#comment-979</link>
		<dc:creator>welpher.yu</dc:creator>
		<pubDate>Sat, 24 Sep 2011 18:40:18 +0000</pubDate>
		<guid isPermaLink="false">http://a.vifix.us/blog/?p=169#comment-979</guid>
		<description>可以不懂不</description>
		<content:encoded><![CDATA[<p>可以不懂不</p>
]]></content:encoded>
	</item>
</channel>
</rss>

