孟岩ID:myan
1628972次访问,排名8好友1人,关注者62
总是在思考存在的问题
myan的文章
原创 147 篇
翻译 0 篇
转载 3 篇
评论 5244 篇
最近评论
chengen81284493:很专业的一篇文章 非常的好 受益匪浅
jksharp:看的迷糊,我才做了一年的程序员,啥都学,我也很专业做的一门,难啊,老板啥都要我做,想写点程序都难,唉,今天要你配下服务器,明天叫你修改下数据库的数据,难
rawa459:补充几句,lua使用一个c语言的子集实现,没有发现枚举(较新版本的C才支持)、动态数组(C99才支持)等,就是这样一个c语言实现了足够强大的功能,我觉得比不上作者,作者是大学教授,并且有一个工作小组。什么时候国人学会平静对待C语言,不要那么浮躁不要那么张扬我们的教授级别的人物也能写出这样的东西,个人不喜欢C++,C和C++从最新的标准看已经决裂。C能够直接实现面向对象编程了,加上一些辅助库可……
rawa459:http://www.codingnow.com/2000/download/The%20Implementation%20of%20Lua5.0.pdf
看看此书,就知道lua的过人之处,本人也在写编译器,始终不敢碰基于寄存器的虚拟机,还是传统的基于堆栈的虚拟机。一个新语言,一个解释器不是很难,关键你要有过人之处,lua的函数闭包、协程、基于寄存器的虚拟机、关系表都是它的过人之处……
rawa459:http://www.codingnow.com/2000/download/The%20Implementation%20of%20Lua5.0.pdf
看看此书,就知道lua的过人之处,本人也在写编译器,始终不敢碰基于寄存器的虚拟机,还是传统的基于堆栈的虚拟机。一个新语言,一个解释器不是很难,关键你要有过人之处,lua的函数闭包、协程、基于堆栈的虚拟机、关系表都是它的过人之处,……
文章分类
收藏
    相册
    测试
    友情链接
    老赵的博客
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 Scott Meyers的新书 Effective STL: 提高STL使用技术的50招收藏

    新一篇: 与大虾对话: 领悟设计模式 | 旧一篇: 对今年内将出版的几本C++书的简评

     

    Effective C++/More Effective C++的作者Scott Meyers即将推出最新力作:Effective STL, 该书目前已经完成,相信不久可以问世。但是与中国读者见面恐怕还是要在苦等之后。Addison=Wesley已经刊出了此书的页面。地址http://cseng.aw.com/book/toc/0,3830,0201749629,00.html

    下面是该书的内容:
    某些条款我基本可以理解,大部分知道应该如此,但不知其所以然,某些条款令我相当诧异,所以更希望能够早日拜读。我对于某些条款的感想用[]写在下面,我相信也是Meyers书中能够解释的东西。如果对于STL感兴趣的网友能够就这些条款展开讨论,我相信是非常有帮助的。

    1. Containers

    Item 1: Choose your containers with care.

    Item 2: Beware the illusion of container-independent code.
            [值得注意的条款!]

    Item 3: Make copying cheap and correct for objects in containers.
            [可以理解,可是如何做到cheap,哪些情况下容易作出不正确的copy操作?]

    Item 4: Call empty instead of checking size against zero.
            [何故?]

    Item 5: Prefer range member functions to their single-element counterparts.
            [何故?]

    Item 6: Be alert for C++'s most vexing parse.
            [谈何容易!]

    Item 7: When using containers of newed pointers, remember to delete the pointers before the container is destroyed.
            [可以理解]

    Item 8: Never create containers of auto_ptrs.
            [可以理解]

    Item 9: Choose carefully among erasing options.
            [非常令我感兴趣的条款]

    Item 10: Be aware of allocator conventions and restrictions.
            [好深入的话题!]

    Item 11: Understand the legitimate uses of custom allocators.
             [怎么做?我略知一二,希望强化这方面的知识]

    Item 12: Have realistic expectations about the thread safety of STL containers.
             [呵呵,重要条款]


    2. Vector and string.

    Item 13: Prefer vector and string to dynamically allocated arrays.
             [对了,basic_string本身就是一个动态数组容器,大家别以为只有vector]

    Item 14: Use reserve to avoid unnecessary reallocations.
             [太对了,vector一旦发现容量(capacity)不足,会以惊人的魄力re-allocate,
       要当心,不然很惨]

    Item 15: Be aware of variations in string implementations.
             [愿洗耳恭听]

    Item 16: Know how to pass vector and string data to legacy APIs.
             [Viva! I know a little bit about that..., but wait a minute, 根据我看
       Effective C++的经验,千万别以为你知道不少,Meyers会狠狠教训你,让你知道
       什么叫做井观天]

    Item 17: Use "the swap trick" to trim excess capacity.
             [哈,我一点都不懂!]

    Item 18: Avoid using vector.
             [惊诧!完全打击!我一直把vector当首选容器!Meyers,我希望你给我个
       不用vector的理由先]


    3. Associative Containers.

    Item 19: Understand the difference between equality and equivalence.
             [戳到死穴,真的不知道两者有何不同,马上查书去]

    Item 20: Specify comparison types for associative containers of pointers.
             [嗯,有道理!]

    Item 21: Always have comparison functions return false for equal values.
             [啊?又一个晴天霹雳!简直匪夷所思嘛!不过想想,啊,Meyers真伟大]

    Item 22: Avoid in-place key modification in set and multiset.
             [不好意思,从来没正儿八经用过set]

    Item 23: Consider replacing associative containers with sorted vectors.
             [好建议!]

    Item 24: Prefer map::insert to map::operator[] when efficiency is a concern.
             [嘿嘿,虽然没仔细想过这个问题,但是我可是一直都使用insert的哟!道理吗, 好想知道那么一点点,不过还是谨慎点好,我怕Meyers又来敲我的头...]

    Item 25: Familiarize yourself with the nonstandard hashed containers.
             [弱点!我还是快去补补课吧!]


    4. Iterators.

    Item 26: Prefer iterator to const_iterator, reverse_iterator, and const_reverse_iterator.
             [晴天霹雳3!不是说要尽可能地用const吗,怎么加了个下划线就不认帐了?不行, 您得给我讲清楚...]

    Item 27: Use distance and advance to convert const_iterators to iterators.
             [丈二和尚]

    Item 28: Understand how to use a reverse_iterator's base iterator.
             [更是连概念都搞不清楚了,reverse_iterator还有base iterator? 赶快去查查书]

    Item 29: Consider istreambuf_iterators for character by character input.
             [唔,值得好好研究]


    5. Algorithms.

    Item 30: Make sure destination ranges are big enough.
             [应该是可以理解的吧!]

    Item 31: Know your sorting options.
             [原则上理解]

    Item 32: Follow remove-like algorithms by erase if you really want to remove something.
             [呵呵,又可以理解!]

    Item 33: Be wary of remove-like algorithms on containers of pointers.
             [好险!这确实是个需要警惕的问题]

    Item 34: Note which algorithms expect sorted ranges.
             [不太清楚...]

    Item 35: Implement simple case-insensitive string comparisons via mismatch or lexicographical_compare.
             [不太清楚...]

    Item 36: Use not1 and remove_copy_if to perform a copy_if.
             [以前在comp.lang.c++.moderated上读到过关于这个条款的故事,很精彩的!Scott Meyers 和Matt Austern都在这个问题上不小心栽了跟头,最后还是Bjarne Stroustrup一锤定音。等毕业论文改完了讲给大家听。]


    Item 37: Use accumulate or for_each to summarize sequences
             [谨遵师命]

    6. Functors, Functor Classes, Functions, etc.

    Item 38: Design functor classes for pass-by-value.
             [概念上有点糊涂]

    Item 39: Make predicates pure functions.
             [晴天霹雳4,Stroustrup不是说Functor可以产生更高效的inline代码吗?为什么predications要例外呢? 俺要个说法。]

    Item 40: Make functor classes adaptable.
             [这个问题跟条款36相关的,看来Meyers真的从copy_if的教训中挖掘出不少宝藏]

    Item 41: Understand the reasons for ptr_fun, mem_fun, and mem_fun_ref.
             [表面上是know了,但是老也想不起用它们来,说明还没有understand]

    Item 42: Make sure less means operator<.
             [从来没想到过这个问题有什么重要性]

    7. Programming with the STL.

    Item 43: Prefer algorithm calls to hand-written loops.
             [我虽然从来都是如此这般作,却不知出了使自己的代码看起来更须cool以外还有什么别的道理]

    Item 44: Prefer member functions to algorithms with the same names.
             [算不上是晴天霹雳,但也很出乎我的意料,我一直以用纯algorithms操作contain为荣]

    Item 45: Distinguish among count, find, binary_search, lower_bound, upper_bound, and equal_range.
             [好像略知一二]

    Item 46: Consider function objects instead of functions as algorithm parameters.
             [这跟条款39不矛盾吗?]

    Item 47: Avoid producing write-only code.
             [不懂]

    Item 48: Always #include the proper headers.

    Item 49: Learn to decipher STL-related compiler diagnostics.
             [谈何容易,尤其是VC]

    Item 50: Familiarize yourself with STL-related web sites.
             [知道一些,还不令我满意]


     

    发表于 @ 2001年05月12日 23:04:00|评论(loading...)|编辑

    新一篇: 与大虾对话: 领悟设计模式 | 旧一篇: 对今年内将出版的几本C++书的简评

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © 孟岩