编程时候经常需要使用定长的容器(fixed size container),比如有时日志只需要保留一周或一个月,或者缓存一天上游发来的数据流。实现一个简单的旋转容器只需要像下面这样就好:std::vector vec(size);vec[i % size] = newelem;boost的circu...
分类:
其他好文 时间:
2015-01-29 14:20:20
阅读次数:
150
std::auto_ptr很多的时候并不能满足我们的要求,比如auto_ptr不能用作STL容器的元素。boost的smart_ptr中提供了4种智能指针和2种智能指针数组来作为std::auto_ptr的补充。
shared_ptr:使用shared_ptr进行对象的生存期自动管理,使得分享资源所有权变得有效且安全.
weak_ptr:weak_ptr 是 shared_ptr 的观察员...
分类:
其他好文 时间:
2015-01-29 09:22:31
阅读次数:
288
1 unzip boost_1_57_0.zip2 ./bootstrap.sh3 ./b2 toolset=gcc cxxflags="-std=c++11" install4 find / -name libboost*.a/usr/local/lib目录下头文件在/usr/local/incl...
分类:
系统相关 时间:
2015-01-28 17:42:40
阅读次数:
1325
(1)ACE庞大、复杂,适合大型项目。开源、免费,不依赖第三方库,支持跨平台。http://www.cs.wustl.edu/~schmidt/ACE.html(2)AsioAsio基于Boost开发的异步IO库,封装了Socket,简化基于socket程序的开发。开源、免费,支持跨平台。http:...
分类:
编程语言 时间:
2015-01-28 17:31:28
阅读次数:
189
#include #include #include #include #include #include using namespace std; using namespace boost; //写一个程序,提取之间的内容 ...
分类:
其他好文 时间:
2015-01-28 17:24:44
阅读次数:
200
看一个别人给出的例子,当我们输入“select 字符串 from 字符串”的时候,会得到输出;如果不符合这个格式,就会输出error。注意:在命令行下输入的时候,按ctrl+Z、回车表示行输入结束。 #include #include #include #include...
分类:
其他好文 时间:
2015-01-28 17:17:42
阅读次数:
187
一种是用boost::atomic;一种直接加锁;代码很简单:
#include
#include
#include
#include
#include
#include
#include
#include
static int loop_num = 10000;
boost::atomic a(0);
static boost::mutex mtx_;
static v...
分类:
系统相关 时间:
2015-01-28 01:01:01
阅读次数:
352
如果你是偶然浏览到这里,请先看源代码及例程下载地址:命令行:svn checkout http://st-asio-wrapper.googlecode.com/svn/trunk/ st-asio-wrapper-read-only如果从svn客户端界面上打开,则只输入http://st-asio...
分类:
移动开发 时间:
2015-01-28 00:56:32
阅读次数:
327
一:什么是st_asio_wrapper它是一个c/s网络编程框架,基于对boost.asio的包装(最低在boost-1.49.0上调试过),目的是快速的构建一个c/s系统;二:st_asio_wrapper的特点效率高、跨平台、完全异步,当然这是从boost.asio继承而来;自动重连,数据透明...
分类:
移动开发 时间:
2015-01-28 00:51:34
阅读次数:
328
=====================
template
class any
{
public:
T m_data;
};
void main()
{
any a;
}
缺点是 必须知道类型,有时我们并不知道某个对象的类型。
-------------
class any
{
public:
template
any...
分类:
其他好文 时间:
2015-01-27 18:21:59
阅读次数:
177