
Boost
mengzhisuoliu
我有我自由你有感受
展开
-
boost 类型转换操作符
struct father { virtual ~father() { }; }; struct mother { virtual ~mother() { }; }; struct child : public father, public mother { }; void func(father *f) { //将f父类的指针 转换为子类的指针,这种原创 2017-11-24 14:19:40 · 654 阅读 · 0 评论 -
boost 异常处理
#include #include //Boost.System boost::system::error_code ec; string hostname=boost::asio::ip::host_name(ec); TRACE("%d\n",ec.value());//错误代码等于0表示OK,否则则是错误代码的编号 TRACE("%s\n",ec.category(原创 2017-11-24 14:01:01 · 7030 阅读 · 0 评论 -
boost 数据结构
#include #include //tuple(元组),他和std::pair类似,只是他不仅仅存储一对数据,可以存储无限多个数据 //tuple使其支持流的输出,需要包含 #include typedef boost::tuple person; std::stringstream strstream; person per("hello","hi",32);原创 2017-11-24 11:32:15 · 491 阅读 · 0 评论 -
boost 容器
//boost::array 和 std::vector 很类似,唯一区别就是boost::array是静态的,不支持动态增加 typedef boost::array array; array a; a[0] = "第一个元素"; //第一个元素 a.at(1) = "第二个元素"; *a.rbegin() = "第三个元素"; //排序 std::sort(a.begi原创 2017-11-23 15:48:20 · 702 阅读 · 0 评论 -
boot 词汇分析器
这是一个简单的json语法分析器,也可以定义自己的分析器,先学习了#include #include #include #include #include struct json_grammar : public boost::spirit::grammar { struct print { void operator()(const cha转载 2017-11-23 15:37:32 · 251 阅读 · 0 评论 -
boost 序列化
#include #include std::stringstream strstream;void save() { boost::archive::text_oarchive oa(strstream); int i = 1; oa << i; //将i的值序列化到strstream 类中 TRACE("%s\n",strstream.str().c_st原创 2017-11-23 11:49:00 · 351 阅读 · 0 评论 -
boost datetime 时间日期
时间日期头文件包含#include try { //boost::gregorian::date 的缺省构造函数会创建一个无效的日期 boost::gregorian::date d(2017,12,23); TRACE("%d年%d月%d日,周%d,月结日%d\n",d.year(),d.month(),d.day(),d.day_of_week(),d.end_of_m原创 2017-11-22 23:39:24 · 763 阅读 · 0 评论 -
boost Filesystem 文件系统
boost::filesystem::path p("C:\\Windows\\System");//这里实际上不会访问文件系统的内容以及路径,仅仅是一个字符串而已 TRACE("%s\n",p.root_name().string().c_str());//这里输出C: TRACE("%s\n",p.root_directory().string().c_str());//返回"\" TR原创 2017-11-20 00:08:36 · 942 阅读 · 0 评论 -
boost interprocess 进程通信
//共享内存void CMFC08Dlg::OnBnClickedButton2(){ // //boost::interprocess::open_or_create 打开或者创建一块新的共享内存 //"Hello":共享内存的名称 //boost::interprocess::read_write:该内存地址可以读写操作 boost::interprocess::shared_原创 2017-11-19 20:29:40 · 5363 阅读 · 0 评论 -
boost asio 异步io
boost::asio::io_service bIOService;//定义一个io_service对象 boost::asio::deadline_timer timer(bIOService,boost::posix_time::seconds(5));//定义一个deadline_timer对象,绑定io_service服务 5秒后执行 timer.async_wait(boost_h原创 2017-11-17 16:02:32 · 524 阅读 · 0 评论 -
boost 多线程
void wait(int seconds){ boost::this_thread::sleep(boost::posix_time::seconds(seconds));//休眠秒数}void boost_thread(){ //新的线程创建 TRACE("当前线程ID,%d\n",GetCurrentThreadId()); for (int i=0;i<5;i++) {原创 2017-11-16 21:46:39 · 806 阅读 · 0 评论 -
boost使用总结
1.boost::variant boost::variant v; v=3.14; v='a'; v="jks";//最后压入了string double v1=boost::get(v);//这里会抛出一个异常,boost::variant 以最后一个为准 char v2=boost::get(v); string v3=boost::get(v); boost::varian原创 2017-11-15 10:17:14 · 4833 阅读 · 0 评论