Boost快速入门

官方入门

http://www.boost.org/doc/libs/1_53_0/more/getting_started/index.html


boost_1_53_0\ .................The “boost root directory”
   index.htm .........A copy of www.boost.org starts here
   boost\ .........................All Boost Header files
   lib\ .....................precompiled library binaries
   libs\ ............Tests, .cpps, docs, etc., by library
     index.html ........Library documentation starts here
     algorithm\
     any\
     array\
                     …more libraries…
   status\ .........................Boost-wide test suite
   tools\ ...........Utilities, e.g. Boost.Build, quickbook, bcp
   more\ ..........................Policy documents, etc.
   doc\ ...............A subset of all Boost library docs

大部分头文件是模板文件,不用build。只有下面的需要编译。

  • Boost.Filesystem
  • Boost.GraphParallel
  • Boost.IOStreams
  • Boost.MPI
  • Boost.ProgramOptions
  • Boost.Python (see the Boost.Python build documentation before building and installing it)
  • Boost.Regex
  • Boost.Serialization
  • Boost.Signals
  • Boost.System
  • Boost.Thread
  • Boost.Wave

常用库

Boost.String_algo

Boost.Tokenizer

Boost.Any  安全地存储和获取任意类型的值

Boost.Array  包装了普通的C 风格数组

Boost.Graph 路径

Boost.MultiArray 多维数组

Boost.Variant  多类型变量

Boost.Signals 发布,订阅


Smart_ptr 库如何改进你的程序?
 使用shared_ptr 进行对象的生存期自动管理,使得分享资源所有权变得有效且安全。
 使用weak_ptr 可以安全地观测共享资源,避免了悬挂的指针。
 使用scoped_ptr 和 scoped_array 限制资源的使用范围,使得代码更易于编写和维护,
并有助于写出异常安全的代码。


本章主要关注 scoped_ptr, shared_ptr, intrusive_ptr, 和 weak_ptr. 虽然剩下的
scoped_array 和 shared_array 有时候也很有用,但它们用的不是很多,而且它们与已讨论的
非常相近,这里就不重复讨论它们了。


1.auto_ptr 被复制后,将失去原来所致资源的所有权;

2.scoped_ptr永远不能被复制或被赋值!scoped_ptr拥有它所指向的资源的所有权,并永远不会放弃这个所有权;

3.shared_ptr 是可以共享所有权的智能指针;


scoped_ptr.reset() 提前删除。


 scoped_ptr pS(p);
if (pS)  //测试是否空指针   unspecified_bool_type
{
     pS.reset();
}


/**********************************************/

总结

一、shared_ptr, intrusive_ptr, weak_ptr  引用计数问题

二、Boost.Array  数组问题

三、

四、


你可能感兴趣的:(Boost_STL)