boost

http://zh.highscore.de/cpp/boost/

std::auto_ptr  析构的时候调用 delete 操作符来自动释放所包含的对象

boost::scoped_ptr / boost::scoped_array不能传递它所包含的对象的所有权 到另一个作用域指针

boost::shared_ptr    / boost::shared_array 在内部记录着引用到某个对象的共 享指针的数量

因为所有权可以在 boost::shared_ptr 之间共享,任何一个共享指针都可以被复制,这跟 boost::scoped_ptr 是不同的。 这样就可以在标准容器里存储智能指针了 ——你不能在标准容器中存储 std::auto_ptr ,因为它们在拷贝的时候传递了所有权

std::vector<boost::shared_ptr<int> > v;  

boost::ptr_vector

boost::ptr_vector<int> v;

 v.push_back(new int(1));

不能传递它所包含的对象的所有权 到另一个作用域指针

boost::bind

boost::ref

boost::cref 以引用方式传递常量对象

boost::function<int (const char*)> f = std::atoi;

boost/signals2.hpp 比boost::function强大,可connect多个func

#include <iostream>

#include <boost/signals2.hpp>

void func() {

    std::cout << "Hello, world!" << std::endl;

}

int main() {

    boost::signals2::signal<void ()> sig;

    sig.connect(func);

    sig();

}

======================================================

ASIO

======================================================

#include <boost/asio.hpp>

#include <iostream>

 

void handler(constboost::system::error_code &ec)

{

    std::cout << "5 s." << std::endl;

}

 

int main()

{

    boost::asio::io_service io_service;

    boost::asio::deadline_timer timer(io_service, boost::posix_time::seconds(5));

    timer.async_wait(handler);

    io_service.run();

}

Xcode add    other linker Flags   -lboost_system -lboost_thread

 

======================================================

 

boost interprocess

 

======================================================

#include <boost/date_time/gregorian/gregorian.hpp>

======================================================

bjam —show-libraries 查看要编译的库

 

- atomic
- chrono
- context
- coroutine
- date_time
- exception
- filesystem
- graph
- graph_parallel
- iostreams
- locale
- log
- math
- mpi
- program_options
- python
- random
- regex
- serialization
- signals
- system
- test
- thread
- timer
- wave


posted @ 2014-05-14 21:57  anjsxz  阅读(266)  评论(0编辑  收藏  举报