如何使用boost对各个类型进行转化
来源:互联网 发布:战龙三国张郺进阶数据 编辑:程序博客网 时间:2024/06/08 01:01
boost 的编译,如果不考虑其的裁剪也很简单,只需要运行下面的命令,耐心等待,就能完成编译了。
bjam.exe --threading=multi install --without python
1.#include <boost\lexical_cast.hpp> 这个头文件是用来进行各种转化,最新版本的boost已经改进了很多以前的0x之类的十六进制数是不能进行转化的,最新版本的boost已经没有了这个限制。我写的例子程序如下:
#include <boost\lexical_cast.hpp>#include<iostream>#include <string>void main(){try{int x = boost::lexical_cast<int>("100");//字符串转化为intdouble a = boost::lexical_cast<double>("3.3");//字符串转化为doublestd::cout<<a;std::string str =boost::lexical_cast<std::string>(333);//int转化为stringstr = boost::lexical_cast<std::string>(0x333);std::cout<<str<<std::endl;}catch(boost::bad_lexical_cast&e){std::cout<<e.what()<<std::endl;}}
boost中的format方法实现格式化输入和输出,我写的例子程序如下:
#include <boost\lexical_cast.hpp>#include<iostream>#include <string>#include<boost/format.hpp>void main(){std::cout<<boost::format("%d")%3;boost::format fom("%d");fom%3;std::string str = fom.str();boost::format form2("%05d");form2%3;str = form2.str();}
0 0
- 如何使用boost对各个类型进行转化
- 对“在EXCEL中如何使用VBA进行格式转化”的改进算法
- java 对各个盘符的使用情况进行查看
- c++ 各个类型之间转化实例
- 使用stringstream对string进行类型转换
- 使用自定义annotation接口进行aspectj动态缓存[要对各个接口进行key-value缓存]
- 对字符串进行编码转化
- 在EXCEL中如何使用VBA进行格式转化
- 如何使用免费工具进行音/视频格式转化
- 如何使用PyCharm对函数进行测试
- 如何使用客户端对ZooKeeper进行操作。
- hibernate如何对Blob类型字段进行数据添加
- java中如何对Double类型进行四舍五入操作
- java的Comparator接口如何对指定类型进行排序。
- 如何在C# DateTime类型和JavaScript的Date之间进行转化
- MFC 中如何对客户区坐标进行转化(SetWindowExt和SetViewportExt)
- 使用boost::enable_if与boost::type_traits在模板中实现对模板类型的接口的限制
- 使用 boost 进行 CRC32 校验
- 字符串统计
- debian7 系统安装配置
- svn 清空
- IOS获取两个时间的毫秒差
- hdoj.2519 新生晚会 20140724
- 如何使用boost对各个类型进行转化
- 杭电ACM 1001 sum problem
- hdu 1267 下沙的沙子有几粒?
- “逃离朋友圈”能否催生新微信
- LeetCode-Word Break II
- 第三方API的调用开发
- hibernate的简单配置
- 关于Build Active Architecture Only属性
- Android系统启动流程 -- android层