<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[分享技术，共建开放平台]]></title><description><![CDATA[http://harttle.land mirror]]></description><link>https://blog.youkuaiyun.com/yangjvn</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; yangjvn]]></copyright><item><title><![CDATA[Item 54：熟悉一下标准库，比如TR1]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50705981</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50705981</guid><author>yangjvn</author><pubDate>Sat, 20 Feb 2016 20:23:48 +0800</pubDate><description><![CDATA[Item 54: Familiarize yourself with the standard library, including TR1.C++这个名字是在1983年由Rick Mascitti提出的，C++的曾用名还有”new C”, “C with Classes”。 1998年ISO/IEC 14882发布了第一个C++标准，就是我们常讲的C++98。后续的标准还包括C++03，C++T...]]></description><category></category></item><item><title><![CDATA[Item 53：注意编译警告]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50705978</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50705978</guid><author>yangjvn</author><pubDate>Sat, 20 Feb 2016 20:23:15 +0800</pubDate><description><![CDATA[Item 53: Pay attention to compiler warnings.


编译警告在C++中很重要，因为它可能是个错误啊！ 不要随便忽略那些警告，因为编译器的作者比你更清楚那些代码在干什么。 所以，

请严肃对待所有warning，要追求最高warning级别的warning-free代码；但不要依赖于warning，可能换个编译器有些warning就不在了。

]]></description><category></category></item><item><title><![CDATA[Item 52：写了placement new就要写placement delete]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50705972</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50705972</guid><author>yangjvn</author><pubDate>Sat, 20 Feb 2016 20:22:45 +0800</pubDate><description><![CDATA[Item 52: Write placement delete if you write placement new“placement new”通常是专指指定了位置的new(std::size_t size, void *mem)，用于vector申请capacity剩余的可用内存。 但广义的”placement new”指的是拥有额外参数的operator new。new和delete是要成对...]]></description><category></category></item><item><title><![CDATA[Item 51：写new和delete时请遵循惯例]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50705970</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50705970</guid><author>yangjvn</author><pubDate>Sat, 20 Feb 2016 20:22:11 +0800</pubDate><description><![CDATA[Item 51: Adhere to convention when writing new and delete.


Item 50介绍了如何自定义new和delete但没有解释你必须遵循的惯例，
 这些惯例中有些并不直观，所以你需要记住它们！

operator
 new需要无限循环地获取资源，如果没能获取则调用”new handler”，不存在”new handler”时应该]]></description><category></category></item><item><title><![CDATA[Item 50：为什么需要自定义new和delete？]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50705966</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50705966</guid><author>yangjvn</author><pubDate>Sat, 20 Feb 2016 20:21:26 +0800</pubDate><description><![CDATA[Item 50: Understand when it makes sense to replace new and delete.


我们在Item 49中介绍了如何自定义new的错误处理函数，以及如何为你的类重载operator
 new。 现在我们回到更基础的问题，为什么我们需要自定义operator
 new或operator
 delete？

检测使用错误。new得到]]></description><category></category></item><item><title><![CDATA[Item 49：new handler的行为]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50697044</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50697044</guid><author>yangjvn</author><pubDate>Fri, 19 Feb 2016 12:02:05 +0800</pubDate><description><![CDATA[Item 49: Understand the behavior of the new-handler.

new申请内存失败时会抛出"bad alloc"异常，此前会调用一个由std::set_new_handler()指定的错误处理函数（”new-handler”）。
set_new_handler()
“new-handler”函数通过std::set_new_handler()来设]]></description><category></category></item><item><title><![CDATA[Item 48：了解模板元编程]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50697040</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50697040</guid><author>yangjvn</author><pubDate>Fri, 19 Feb 2016 12:01:18 +0800</pubDate><description><![CDATA[Item 48: Be aware of template metaprogramming.模板元编程（Template Metaprogramming，TMP）就是利用模板来编写那些在编译时运行的C++程序。 模板元程序（Template Metaprogram）是由C++写成的，运行在编译器中的程序。当程序运行结束后，它的输出仍然会正常地编译。C++并不是为模板元编程设计的，但自90年代以来，...]]></description><category></category></item><item><title><![CDATA[Item 47：使用Traits类提供类型信息]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50697039</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50697039</guid><author>yangjvn</author><pubDate>Fri, 19 Feb 2016 12:00:20 +0800</pubDate><description><![CDATA[Item 47: Use traits classes for information about types.


C++中的 Traits 类可以在编译期提供类型信息，它是用Traits模板及其特化来实现的。 通过方法的重载，可以在编译期对类型进行”if…else”判断。我们通过STL中的一个例子来介绍Traits的实现和使用。

本文以iterator_traits为例介绍了如何实]]></description><category></category></item><item><title><![CDATA[Item 46：需要类型转换时，应当在类模板中定义非成员函数]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50696990</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50696990</guid><author>yangjvn</author><pubDate>Fri, 19 Feb 2016 11:52:59 +0800</pubDate><description><![CDATA[Item 46: Define non-member functions inside templates when type conversions are desired.


Item 24中提到，如果所有参数都需要隐式类型转换，该函数应当声明为非成员函数。 Item
 24是以Rational和operator*为例子展开的，本文把这个观点推广到类模板和函数模板。
 但是在类模板]]></description><category></category></item><item><title><![CDATA[Item 45：使用成员函数模板来接受所有兼容的类型]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50696964</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50696964</guid><author>yangjvn</author><pubDate>Fri, 19 Feb 2016 11:49:39 +0800</pubDate><description><![CDATA[Item 45: Use member function templates to accept “all compatible types”.

Item 13提到智能指针可用来自动释放堆中的内存，STL中的迭代器也是一种智能指针，它甚至支持链表元素指针的++操作。 这些高级特性是普通指针所没有的。本文以智能指针为例，介绍成员函数模板的使用：

成员函数模板可以使得函数可以接受所有兼容的]]></description><category></category></item><item><title><![CDATA[Item 44：将参数无关代码重构到模板外去]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/50696862</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/50696862</guid><author>yangjvn</author><pubDate>Fri, 19 Feb 2016 11:37:33 +0800</pubDate><description><![CDATA[Item 44: Factor parameter-independent code out of templates.模板是个好东西，你可以在实现类型安全的同时少写很多代码。但模板提供的是编译期的多态， 即使你的代码看起来非常简洁短小，生成的二进制文件也可能包含大量的冗余代码。 因为模板每次实例化都会生成一个完整的副本，所以其中与模板参数无关的部分会造成代码膨胀（code bloat）。把模板中...]]></description><category></category></item><item><title><![CDATA[CSS选择符总结]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/49335031</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/49335031</guid><author>yangjvn</author><pubDate>Thu, 22 Oct 2015 16:15:23 +0800</pubDate><description><![CDATA[我们知道CSS是由选择符和属性/值列表构成的，选择符的重要性自然不言而喻。 作为前端开发者选择符想必不是问题，然而前几天面试还真问到了~和+是干吗用的！
 长时间不用的选择符自然就会忘了，来总结一下吧！

万维网联盟在 HTML 4.0 之外提出层叠样式表（CSS），使用CSS完成样式与内容的分离。层叠样式表（Cascading Style Sheets，CSS）， 又称串样式列表、层次结构]]></description><category></category></item><item><title><![CDATA[Item 43：访问模板基类中的名称 Effective C++笔记]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/49303501</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/49303501</guid><author>yangjvn</author><pubDate>Wed, 21 Oct 2015 13:55:23 +0800</pubDate><description><![CDATA[Item 43: Know how to access names in templatized base classes.


从面相对象C++转移到模板C++时，你会发现类继承在某些场合不在好使了。 比如父类模板中的名称对子类模板不是直接可见的，需要通过this->前缀、using或显式地特化模板父类来访问父类中的名称。

因为父类模板在实例化之前其中的名称是否存在确实是不确定的，而]]></description><category></category></item><item><title><![CDATA[Item 42：typename的两种用法 Effective C++笔记]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/49276045</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/49276045</guid><author>yangjvn</author><pubDate>Tue, 20 Oct 2015 13:19:18 +0800</pubDate><description><![CDATA[Item 42: Understand the two meanings of typename.


时至今日还有人在论坛里问模板参数前的typename和class有何区别：

templatetypename T> class Widget;
templateclass T> class Widget;



答案是没有区别！有人觉得class写起来方便就用class，有人觉]]></description><category></category></item><item><title><![CDATA[Item 41：隐式接口与编译期多态 Effective C++笔记]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/49225321</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/49225321</guid><author>yangjvn</author><pubDate>Sun, 18 Oct 2015 07:41:37 +0800</pubDate><description><![CDATA[Item 41: Understand implicit interfaces and compile-time polymorphism.面向对象设计中的类（class）考虑的是显式接口（explicit interface）和运行时多态， 而模板编程中的模板（template）考虑的是隐式接口（implicit interface）和编译期多态。对类而言，显式接口是由函数签名表征的，运行时多态...]]></description><category></category></item><item><title><![CDATA[Item 40：明智地使用多继承 Effective C++笔记]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/49123673</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/49123673</guid><author>yangjvn</author><pubDate>Wed, 14 Oct 2015 12:58:44 +0800</pubDate><description><![CDATA[Item 40: Use multiple inheritance judiciously.


多继承（Multiple Inheritance，MI）是C++特有的概念，在是否应使用多继承的问题上始终争论不断。一派认为单继承（Single Inheritance，SI）是好的，所以多继承更好； 另一派认为多继承带来的麻烦更多，应该避免多继承。本文的目的便是了解这两派的视角。具体从如下三个]]></description><category></category></item><item><title><![CDATA[Item 39：明智地使用private继承 Effective C++笔记]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/49105685</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/49105685</guid><author>yangjvn</author><pubDate>Tue, 13 Oct 2015 22:33:00 +0800</pubDate><description><![CDATA[Item 39: Use private inheritance judiciously.


Item 32提出public继承表示"is-a"的关系，这是因为编译器会在需要的时候将子类对象隐式转换为父类对象。 然而private继承则不然：

class Person { ... };
class Student: private Person { ... };     // inh]]></description><category></category></item><item><title><![CDATA[Item 38：通过组合表示"拥有"或"以...实现"的关系 Effective C++笔记]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/48827417</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/48827417</guid><author>yangjvn</author><pubDate>Wed, 30 Sep 2015 12:35:13 +0800</pubDate><description><![CDATA[Item 38: Model "has-a" or "is-implemented-in-terms-of" through composition.


一个类型包含另一个类型的对象时，我们这两个类型之间是组合关系。组合是比继承更加灵活的软件复用方法。 Item
 32提到public继承的语义是"is-a"的关系。对象组合也同样拥有它的语义：

就对象关系来讲，组合意味着一个对象拥]]></description><category></category></item><item><title><![CDATA[Item 37：不要重写父类函数的默认参数]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/48804719</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/48804719</guid><author>yangjvn</author><pubDate>Tue, 29 Sep 2015 11:30:30 +0800</pubDate><description><![CDATA[Item 37: Never redefine a function's inherited default parameter value.


不要重写父类函数的默认参数。Item 36已经说明子类中不应该重写继承而来的父类的非虚函数。
 那么本文讨论的内容其实是：不要重定义虚函数的默认参数。为什么呢？ 因为虽然虚函数的是动态绑定的，但默认参数是静态绑定的。只有动态绑定的东西才应该被重]]></description><category></category></item><item><title><![CDATA[Item 36：不要重写继承来的非虚函数]]></title><link>https://blog.youkuaiyun.com/yangjvn/article/details/48782601</link><guid>https://blog.youkuaiyun.com/yangjvn/article/details/48782601</guid><author>yangjvn</author><pubDate>Mon, 28 Sep 2015 11:35:35 +0800</pubDate><description><![CDATA[Item 36: Never redefine an inherited non-virtual function.


我们还是在讨论public继承，比如Derived继承自Base。如果Base有一个非虚函数func，那么客户会倾向认为下面两种调用结果是一样的：

Derived d;
Base* pb = &d;
Derived* pd = &d;
// 以下两种调用应当等效
p]]></description><category></category></item></channel></rss>