Boost基础例子
来源:互联网 发布:立式数控车床编程 编辑:程序博客网 时间:2024/06/13 01:57
在vs2013中,环境配置参考其它blog
基础类型转换与定义
#include "stdafx.h"
#include <boost/lexical_cast.hpp>#include <iostream>
using namespace std;
int mainx()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.0123456789");
string s0 = lexical_cast<string>(a);
string s1 = lexical_cast<string>(b);
cout << "number: " << a << " " << b << endl;
cout << "string: " << s0 << " " << s1 << endl;
int c = 0;
try{
c = lexical_cast<int>("abcd");
}
catch (boost::bad_lexical_cast& e){
cout << e.what() << endl;
}
return 0;
}
timer计时
void timerdemo(){boost::timer t;long long sum = 0;for (int i = 0; i < 1000000; i++)sum = sum + i;cout << "max timespan: " << t.elapsed_max() / 3600 << "h" << endl;cout << "min timespan: " << t.elapsed_min() << "s"<<endl;//用时cout << "now time elapsed: " << t.elapsed() << "s" << endl;}
进度条例子
void progress_display_demo(){std::vector<string> v(100000);std::ofstream fs("c:\\log4j-2016-02-18.log");progress_display pd(v.size());std::vector<string>::iterator pos;for (pos = v.begin(); pos != v.end(); ++pos){fs << *pos << endl;++pd;}}
0 0
- Boost基础例子
- [Boost基础]Boost概述
- boost 基础
- Boost基础
- boost regex 简单例子
- boost test中的例子
- boost::time_wait的例子
- boost socket编程 例子
- boost网络编程例子
- boost socket编程 例子
- boost xpressive 例子
- boost asio allocation 例子
- boost创建线程例子
- boost lexical_cast例子
- 【Boost】boost::algorithm的几个简单例子
- 【Boost】boost库的随机数的例子
- 【Boost】boost库的随机数的例子
- 【Boost】boost库的随机数的例子
- 上世纪最大骗局--windows扩展名背后的故事
- 理头发的奇思妙想-如何设计自动化理发体验
- Java学习:解数独的小程序
- 堆栈和栈帧
- POJ--1182 食物链
- Boost基础例子
- Servlet API 中文版
- 阿里云服务器的MySQL莫名其妙的挂了 之 优化篇
- 隐马尔可夫模型Hidden Markov Model
- 容易混淆的知识点
- poj1426 Find The Multiple
- 值得推荐的C/C++框架和库 (真的很强大)
- View滚动帮助类ViewDragHelper解析
- %-3d在C语言中的含义是什么?