Effective STL 学习笔记: 多用 vector & string如果可能的话, 尽量避免自己去写动态分配的数组,转而使用 vector 和 string 。原书作者唯一想到的一个不用 string 的可能的理由,就是 string 所使用的引用计数 (reference counting) 在多线程下可能会因为并发控制反而导致性能下降。我们可以通过查看文档或者 STL 源面的方法来看 String 是否引入了引用计数,如果 string 在多线程下真的因为引用计数而导致了性能下降,我们可以通过下面的方法来避免:看是否可以通过某些方法来禁用引用计数,例如条件编译 该方法可移植 Read More
posted @ 2013-10-30 22:09 英超 Views(546) Comments(0) Diggs(0) Edit
Table of Contents1. STL, Thread and SGI2. STL and Lock2.1. RAII2.2. Use Lock in STL1 STL, Thread and SGIC++98 以及之前的 C++ 标准中,并未对线程做出过规定,但对于 STL 来讲,SGI 做出了自己的规定,很多其他的 STL 实现也遵循这些规定:The SGI implementation of STL is thread-safe only in the sense that simultaneous accesses to distinct containers are safe Read More
posted @ 2013-10-30 17:32 英超 Views(711) Comments(0) Diggs(0) Edit
Effective STL 笔记 – Item 6 ~ 7: Container and Object Pointer中间两次笔记被删掉了,简单补一下:Item 3 中提到如果将对象直接放入容器中,可能会引发问题:大量的拷贝行为要求对象的拷贝构造代价要小试图将派生类放入存放基类的容器中会引发 Slicing 问题。对此的简单方法就是在容器中保存对象 指针 ,但如果直接保存指针的话,我们需要自己维护和管理内存,容易混乱。最好的方法是保存 智能指针(smart pointer shared_ptr)) 。需要注意的是,这里提倡的是 shared_ptr,不是 autoptr,C++ 标准要求不能声 Read More
posted @ 2013-10-30 14:48 英超 Views(284) Comments(0) Diggs(0) Edit
How to omit h1 title heading in HTML export Introduce how to omit h1 title in the exported html. Sometimes it would be better to omit h1 title in exported HTML, and there is an ema... Read More
posted @ 2013-10-30 14:22 英超 Views(317) Comments(0) Diggs(0) Edit
Introduction to MWB Minor Mode Table of Contents 1. Introduction 2. Usage 1 Introduction MWB stands for "MetaWeblog", it is an submode for org mode and can be used to publish ... Read More
posted @ 2013-10-30 14:21 英超 Views(287) Comments(0) Diggs(0) Edit