11 2011 档案

linux kernel 中的二叉树搜索 与 stl 相应物的对比
摘要:代码Linux kernel 中也使用并实现了红黑树,但是查找算法没有自己实现,而是希望使用者去实现。如果只是实现一个精确查找的函数,这很简单,几乎每个人都能写出正确的代码:static inline struct page * rb_search_page_cache(struct inode * inode, unsigned long offset){ struct rb_node * n = inode->i_rb_page_cache.rb_node; struct page * page; while (n) { page = rb_entry(n, struct p... 阅读全文

posted @ 2011-11-26 22:11 能发波 阅读(218) 评论(0) 推荐(0)

C++ Question: using
摘要:看看这段代码:#include struct A { void f() { printf("A::f\n"); }};struct B : A { using A::f; // #1 void f() { printf("B::f\n"); } // #2};int main() { B().f(); #3 return 0;}运行结果会如何呢?A. B::fB. #1 编译错C. #2 编译错D. #3编译错 阅读全文

posted @ 2011-11-20 09:49 能发波 阅读(98) 评论(0) 推荐(0)

C++ 2-phase lookup
摘要:This 2-phase look up of g++ (gnu C++) seems not inconsistency: builtin types are not treat equivalent with user defined type.#include class A {}; void f(A) { printf("%s\n", __PRETTY_FUNCTION__); }class B {};// now g(T) knew A,B,int,...// phase 1 lookup just success for f(A)template void g( 阅读全文

posted @ 2011-11-11 14:46 能发波 阅读(174) 评论(0) 推荐(0)

导航