boost::ptr_vector
这是我在学习陈硕muduo网络库过程中记录的关于C++的知识碎片,对muduo感兴趣的同学可以加入QQ群365972535一起讨论:
boost::ptr_vector 官网例子
代码/home/chenzw/jmuduo/tests/ptr_vector.cc
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/shared_ptr.hpp>
//#include <boost/lambda/lambda.hpp>
#include <iostream>
//#include <algorithm>
using namespace std;
//
// A simple polymorphic class
//
class Poly
{
int i_;
static int cnt_;
public:
Poly() : i_( ++cnt_ ) { cout << " construct cnt_ = " << cnt_ << endl;}
virtual ~Poly() { cout << " destroy i_ = " << i_ << endl; }
void foo() { doFoo(); }
private: