[boost]lexical_cast简介
来源:互联网 发布:ubuntu qq2015下载 编辑:程序博客网 时间:2024/06/10 13:54
函数声明:
template <typename Target, typename Source>inline Target lexical_cast(const Source &;
lexical_cast将入参转换成和返回值相同类型,如果发生异常,则抛出boost::bad_lexical_cast的异常:
string s("1895x");try{int i = boost::lexical_cast<int>(s);cout<<i<<endl;}catch (boost::bad_lexical_cast& bad){cout<<bad.what()<<endl;}
关于lexical_cast的实现:
本质使用了ostream,这里也可以自己实现一个,比如:
namespace sr{template<typename DestType,typename SrcType>DestType lexical_cast(SrcType src){stringstream os;os<<src;DestType dest;os>>dest;return dest;}}
- [boost]lexical_cast简介
- Boost::lexical_cast
- Boost :Lexical_cast
- boost::lexical_cast
- boost lexical_cast
- boost::lexical_cast
- boost lexical_cast
- boost::lexical_cast
- BOOST-lexical_cast
- boost翻译(1):lexical_cast
- 学习boost之lexical_cast
- 万能转换器boost::lexical_cast
- 万能转换器boost::lexical_cast
- boost lexical_cast使用
- boost lexical_cast使用
- boost学习之-lexical_cast
- 编程:Boost组件lexical_cast
- boost lexical_cast format
- 时间记录
- C# WPF 快速开发07ADO.NET操作数据库
- OpenCV watershed 源码分析
- 记录下测试相关的国外网站
- jstl标签
- [boost]lexical_cast简介
- 网络编程HTTP/FTP连接
- C# WPF 快速开发08数据库连接配置config
- HDU-1287破译密码
- 程序员必学的Photoshop技术之制作(一)圆角矩形图片
- mac 使用小技巧
- 分析案情
- Oracle中TO_DATE TO_CHAR格式
- Linux代码性能检测利器(一)--OProfile概述