
BOOST
奈何小洪
我奋斗,我青春
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
boost::date_time之时间处理
前言:在日常生活中,关于 日期和时间的处理都很复杂,date_time库有很多工具来简化工作,比如日期、时间迭代器以指定的时间间隔来遍历时间,boost::posix_time库能获取系统当前具体的时间,可以把时间和c语音内置的ts结构体相互转化,根据需要转化时间电脑格式和已经不同初始化时间的方法,boost的date_time库都为我们做了很多。虽然date_time不能处理1400原创 2015-03-26 15:21:32 · 3360 阅读 · 1 评论 -
boost::function 用法简介
boost::function 就是一个函数的包装器(function wrapper),用来定义函数对象。1. 介绍 Boost.Function 库包含了一个类族的函数对象的包装。它的概念很像广义上的回调函数。其有着和函数指针相同的特性但是又包含了一个调用的接口。一个函数指针能够在能以地方被调用或者作为一个回调函数。boost.function能够代替函数指转载 2015-03-18 17:47:53 · 933 阅读 · 0 评论 -
使用enable_shared_from_this
使用enable_shared_from_this说明The header defines the class template enable_shared_from_this. It is used as a base class that allows a shared_ptr to the current object to be obtained from within转载 2015-10-21 11:52:50 · 661 阅读 · 0 评论 -
boost读写锁实现
//#########测试多线程,读写锁,递归锁 #include #include #include #include #include #include #include #include #include #include #include #include #define THREAD_COUNT 100转载 2015-11-05 09:53:46 · 1494 阅读 · 0 评论 -
boost::enable_shared_from_this分析
为什么需要boost::enable_shared_from_this? C++代码 class cat{}; shared_ptr p(new cat); shared_ptr p2(p); class cat:public boost::enable_shared_frome_this{}; sh转载 2015-07-27 10:20:56 · 1098 阅读 · 0 评论 -
boost::filesystem常用用法详解
提示:filesystem库提供了两个头文件,一个是,这个头文件包含主要的库内容。它提供了对文件系统的重要操作。同时它定义了一个类path,正如大家所想的,这个是一个可移植的路径表示方法,它是filesystem库的基础。一个是,是对std::fstream的一个补充,使用可以使用类boost::path作为参数,从而使得filesystem库与标准库的关系更亲密。由于文件系统对于大多原创 2015-03-18 16:12:29 · 22616 阅读 · 0 评论 -
boost::tokenizer分词器
tokenizer - Break of a string or other character sequence into a series of tokens, from John Bandelatokenizer - 分解字串,提取内容.作者: John Bandela例一:// simple_example_1.cpp#include#include#inclu转载 2015-03-10 14:13:24 · 952 阅读 · 0 评论 -
boost::lexical_cast常见用法详解之万能转换
提示:虽然在c中可是使用类似于atoi之类的函数对字符串转换成整型,但是我们在这儿还是推荐使用这个函数如果转换发生了错误,lexical_cast会抛出一个bad_lexical_cast异常,因此程序中需要对其进行捕捉。下面是程序示例:#include #include using namespace std; using namespace boo原创 2015-03-18 17:11:44 · 11503 阅读 · 0 评论 -
boost库读写锁与互斥锁的用法解析
#include #include #include typedef boost::shared_mutex WR_Mutex;typedef boost::unique_lock writeLock;typedef boost::shared_lock readLock;WR_Mutex lkey;当在用户读一块内存区域时,使用读锁,防止多个线程同时访原创 2015-03-10 11:33:12 · 6207 阅读 · 0 评论 -
boost常用库用法及其实例
1.boost::anyboost::any是一种通用的数据类型,可以将各种类型包装后统一放入容器内,最重要的它是类型安全的。有点象COM里面的variant。使用方法:any::type() 返回包装的类型any_cast可用于any到其他类型的转化#include void test_any(){ typedef s原创 2015-03-10 11:44:07 · 999 阅读 · 0 评论 -
boost::timer之时间处理器
提示:timer类主要是用于测量时间的间距,是一个小型的计时器。时间可以精确到毫秒级。具体示例:#include #include int _tmain(int argc, _TCHAR* argv[]){ boost::timer t; cout << "max" << t.elapsed_max() / 3600 << " h" << endl; //用于查看tim原创 2015-03-20 19:06:55 · 2138 阅读 · 0 评论 -
boost::smart_ptr之智能指针
前言:1.scoped_ptr 智能指针使用说明示例代码:#include "stdafx.h"#include #include using namespace std;using namespace boost;class posix_file{public: posix_file(const char * file_name) { cout <<原创 2015-03-27 16:17:45 · 1279 阅读 · 0 评论 -
boost库的初步使用方法
本总结只是针对于boost1.54.0版本库: 1.判断文件是否存在:#include std::string m_parent_dir;m_parent_dir.append(“C://user.bat”);boost::filesystem::exists(m_parent_dir) 2.创建文件路径或者文件#include boost::system:原创 2015-01-27 11:59:12 · 3681 阅读 · 0 评论 -
boost::threadpool线程池使用实例
前言:什么是多线程?比如在做一些下载的程序时,同时开启5个下载任务,对应的其实就是多线程。在一些多线程的程序中,响应请求的个数(即线程)的个数过多的话就会造成系统资源损耗过多而宕机,一般最多线程是有上限的,而且每次创建线程和销毁线程都会大量损耗资源和时间。所以解决办法之一就是使用线程池控制线程个数,复用创建过的线程。线程池可以减少创建和切换线程的额外开销,利用已经存在的线程多次循环执行原创 2015-03-20 10:33:04 · 27397 阅读 · 0 评论 -
boost::algorithm用法详解之字符串关系判断
下面先列举几个常用的:#define i_end_with boost::iends_with#define i_start_with boost::istarts_with#define i_contain boost::icontains#define i_equal boost::iequals#define split boost::algorithm::split转载 2015-03-18 17:58:39 · 13548 阅读 · 0 评论