09 2011 档案

is_trivially_destructible replaced has_trivial_destructor
摘要:C++11 中的 type_traits, 改变了一些约定成俗的名字:我们经常使用的 has_trivial_destructor, 变成了is_trivially_destructible, 现在已有不少编译器实现了 has_trivial_destructor, (std, std::tr1). 如此, 要写可移植的代码, 要么使用 tr1, 要么使用 boost, 鉴于 tr1 出现的比 boost 更晚, boost 一般是首选, 而新的编译器往往自带了 tr1, 而 boost 要另外安装.........We think in general, but we live in det 阅读全文

posted @ 2011-09-29 13:42 能发波 阅读(351) 评论(0) 推荐(0)

文章简介最多240个字符
摘要:忽然以前文章中有个笔误, 打算修改一下, 修改好了, 提交, 结果被提示:文章简介最多240个字符, 你已经有输入了247个!可我无论如何找不到 "文章简介" 的输入框! 难道是 IE Only 的? 阅读全文

posted @ 2011-09-28 13:24 能发波 阅读(126) 评论(0) 推荐(0)

HashMap<string, ...> 能有多快
摘要:看到很多使用 map 的代码, 也有一些使用了 unordered_map 或者 hash_map, 当然, hash_map 不是标准的, unordered_map 也只在 boost, tr1 和 c++0x 中可用. 从代码的简洁性和可移植性上讲, 标准的 std::map 是首选.然而, 从另一方面看, gcc 的 string 是 refcounted & copy on write 的, 64 位环境下, 一个 string 的额外开销是 32 字节, 如果加上 string 内容的额外对齐(8 byte align)开销, 则上升到平均至少 36 字节. 所以哪怕我的 阅读全文

posted @ 2011-09-25 12:56 能发波 阅读(306) 评论(0) 推荐(0)

怎样让C++函数重载时连返回值类型也加入重载决议?
摘要:众所周知,C++函数重载时返回值是不参与重载决议的, 也就是说:int lex_cast(const char*);double lex_cast(const char*);这样两个函数在同一个编译单元同一个 namespace 中时, 会编译报错.怎么办呢?一个小技巧:#include #include #include class my_cast { const char* s;public: template operator Target() const { return boost::lexical_cast(s); } my_cast(c... 阅读全文

posted @ 2011-09-07 11:35 能发波 阅读(199) 评论(0) 推荐(0)

导航