关于某个类型转字符串和字符串转换某种类型的简单实现(用字符串流)

template<typename T>
T from_string(
const std::string &s)
{
    std::istringstream 
is(s);
    T type;
    
is >> type;
    
return t;
}

template
<typename T>
std::
string to_string(const T &type)
{
    std::ostringstream s;
    s 
<< type;
    
return s.str();
}

直接用字符串流方便的处理了各种内嵌类型


做个标记,回家了

posted on 2011-06-09 18:22 Hallelujah 阅读(242) 评论(0)  编辑 收藏 引用 所属分类: C++学习


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2011年6月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

导航

统计

常用链接

留言簿(1)

随笔分类(15)

随笔档案(14)

最新随笔

搜索

最新随笔

最新评论

阅读排行榜

评论排行榜