文章分类 -  Corners

Language corners... These may have puzzled you ever for a long time. Let's record these and review when need.
摘要:Let's see the piece of code below:Obviously, `foo(false)` will call `foo(bool)` as excepted.But do you know what does `foo("1234")` actually select? The answer is `foo(bool)` too! See here for detail:http://stackoverflow.com/questions/13268608/boostvariant-why-is-const-char-converted-t 阅读全文
posted @ 2013-08-04 13:00 walfud 阅读(202) 评论(0) 推荐(0)
摘要:1. 对于 mbs(multi-byte-string) 而言, 在 string 中的 size 返回的是所占字节的大小.2. 某些字符 mbs 是无法表示的. 比如 “𪚥” 这样字符. Vs 2008/2012 中的 mbs(std::string 以及 vc 9 中 atl 的 CString), 对于无法转换的字符都以 3f 填充. 下图以 std::string 为例.3. 之前发的连接中给的算法是对的: http://blog.csdn.net/wallaceli1981/article/details/5740618对于 wcstombs 需要 4 倍于原 wcs 阅读全文
posted @ 2013-06-22 15:47 walfud 阅读(2169) 评论(1) 推荐(0)
摘要:bool foo() { unsigned int a = 6; int b = -20; // If 'b' is 'long long'? return a + b < 6 ? true : false; } If 'int b = -20;', the result is false, because 'a + b' => (unsigned + int) => (unsigned + unsigned) in integral promotion. Thus result is unsigned(-14) 阅读全文
posted @ 2013-02-19 17:57 walfud 阅读(323) 评论(0) 推荐(0)
摘要:static constunsigned *s_someNames[aConstexpr];storage _ cv-qualification _type+ operator _ declarator-id _ operator;declarationdeclarator;put 'const' specifier to right of declaration is goes from here:http://www.dansaks.com/articles/1999-02%20const%20T%20vs%20T%20const.pdfI thouht 'cons 阅读全文
posted @ 2013-01-20 11:33 walfud 阅读(382) 评论(0) 推荐(0)
摘要:class T{ int *m_p; void foo() const { *m_p = 1234; }}; 不谈 'm_p' 的初始化及资源释放问题. 在 const member function 中, 竟然能修改类的成员变量? 这并不奇怪, 因为 const 成员函数的实质是: 不改变类的成员变量的值. 由于 'm_p' 是一个指针, 所以 const 的保护作用只能做用于不修改这个指针的值, 而不能限制指针所指向的内存的值.reference: http://bbs.csdn.net/topics/40265282 阅读全文
posted @ 2013-01-20 10:32 walfud 阅读(201) 评论(0) 推荐(0)
摘要:'HeapCreate()' s second parameter ensures there will be a region which is equal or large than 'dwInitialSize'. 阅读全文
posted @ 2012-10-15 14:13 walfud 阅读(247) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2012-08-12 13:31 walfud 阅读(164) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2012-02-14 14:32 walfud 阅读(262) 评论(0) 推荐(0)
摘要:terminal 阅读全文
posted @ 2011-10-11 13:41 walfud 阅读(317) 评论(0) 推荐(0)
摘要:ASCII 的设计不得不让人佩服, 很多考虑是你意想不到的. 阅读全文
posted @ 2011-08-30 16:34 walfud 阅读(231) 评论(1) 推荐(0)
摘要:字符串转义后的含义??=#??([??)]??/\??<{??>}??'^??!|??-~原文:http://www.cppblog.com/cc/archive/2006/07/30/10709.html 阅读全文
posted @ 2011-08-26 22:37 walfud 阅读(157) 评论(0) 推荐(0)
摘要:alpha, beta, gamma... and then ? 阅读全文
posted @ 2011-08-26 08:05 walfud 阅读(394) 评论(0) 推荐(0)
摘要:%[*] [width] [{h | l | ll | I64 | L}]type 阅读全文
posted @ 2011-08-06 18:11 walfud 阅读(363) 评论(0) 推荐(0)
摘要:术语 定义 例子形参 (parameter) 它是一个变量, 在函数定义或函数声明的 int power(int base, int n); 原型中定义. 又称 "形式参数 (formal base 和 n 都是形参 parameter)"实参 (argument) 在实际调用一个函数时所传递给函数的 i = power(10, j); 值, 又称 "实际参数 (actual argument)" 10 和 j 都是实参. 在同一个函数的多次调用 时, 实参可以不同 阅读全文
posted @ 2011-07-25 22:28 walfud 阅读(777) 评论(0) 推荐(0)
摘要:退化的规则: 这个数组里存放的是什么, 那么其退化后的指针里存放的也得是什么. 阅读全文
posted @ 2011-07-24 11:36 walfud 阅读(169) 评论(0) 推荐(0)
摘要:定义一个数组并声明为一个指针时, 会导致严重的运行时错误. 因为其底层取值操作是不一样的: 指针比数组多了一层取地址操作. 阅读全文
posted @ 2011-07-20 14:20 walfud 阅读(1713) 评论(0) 推荐(0)
摘要:C/C++ 中几乎可以完成任何类型的声明, 但是唯独这几种除外. 阅读全文
posted @ 2011-07-20 07:50 walfud 阅读(152) 评论(0) 推荐(0)
摘要:typedef 只是已知类型的一种组合的封装. 善用可增加代码可读性和方便, 滥用则造成迷惑和错误. 阅读全文
posted @ 2011-07-19 21:29 walfud 阅读(169) 评论(0) 推荐(0)
摘要:. 优先级高于 **p.f // *(p.f): 对 p 取 f 偏移, 作为指针, 然后进行解除引用操作[] 高于 *int *ap[] ; // int *(ap[]): ap是个元素为 int 指针的数组函数 () 高于 *int *fp() ; // int *(fp()): fp 是个函数, 返回 int *++ 高于 *const char *p = "123456789" ;while ('\0' != *p++) { // ...}!= 高于任何位运算(var & mask != 0) ; // var & (mask != 阅读全文
posted @ 2011-07-17 23:09 walfud 阅读(144) 评论(0) 推荐(0)
摘要:From <The C Programming Language>(p.53)OPERATORSASSOCIATIVITY ( ) [ ] -> .Left to right ! ~ ++ -- + - * & ( type ) sizeofRight to left * / %Left to right + -Left to right << >>Left to right < <= > >=Left to right == !=Left to right &Left to right ^Left to rig 阅读全文
posted @ 2011-05-18 22:21 walfud 阅读(958) 评论(3) 推荐(0)