STL高效编程(英文影印版)[按需印刷]
基本信息
- 原书名: Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library
- 原出版社: Addison-Wesley/Pearson
- 作者: (美)Scott Meyers [作译者介绍]
- 丛书名: C++设计新思维系列丛书
- 出版社:机械工业出版社
- ISBN:7111196244
- 上架时间:2006-8-3
- 出版日期:2006 年8月
- 开本:16开
- 页码:260
- 版次:1-1
- 所属分类:
计算机 > 软件与程序设计 > C++ > STL
推荐阅读
内容简介回到顶部↑
所有的c++程序员都必读的书少之又少,而本书就是其中的一本。
c++的标准模板库(stl)是革命性的,但是要想学会用好stl却充满了挑战性。中国台湾技术作家侯捷先生曾经把stl的学习过程比喻为三个境界:
第一境界:熟用stl。
第二境界:了解泛型技术的内涵与stl的学理乃至实作。
第三境界:扩充stl。
本书无疑是你达到第二境界的最佳读本。在本书中,c++技术权威scott meyers揭示了专家总结的一些关键规则,包括他们总是采用的做法以及总是避免的做法。这些规则可以发挥stl的最大效用。
有些书只是描述stl中有些什么内容,而本书则讲述如何使用stl。本书共有50条指导原则,在讲述每一条指导原则时,scott meyers都提供了透彻的分析和深刻的实例,所以读者不仅可以学到要做什么,而且还能够知道什么时候该这样做,以及为什么要这样做。
如同meyers的其他著作一样,本书充满了从实践中总结出来的智慧。清晰、简明、透彻的风格使本书成为每一位stl程序员的案头必备。
本书特色
·关于选择容器的建议,涉及的容器有:标准stl容器(例如vector和list)、非标准的stl容器(例如hash_set和hash_map),以及非stl容器(例如bitset)。
·一些提高效率的技术,通过它们可以最大程度地提高stl(以及使用stl的程序)的效率。
·深入到迭代器、函数对象和分配子(allocator)的行为,也包括程序员总是应该避免的做法。
·对于那些同名的算法和成员函数,如find,根据它们行为方式上的微妙差异,本书给出了一些指导原则,以保证它们能被正确地使用。
·讨论了潜在的移植性问题,包括避免这些移植性问题的各种简单途径。
c++的标准模板库(stl)是革命性的,但是要想学会用好stl却充满了挑战性。中国台湾技术作家侯捷先生曾经把stl的学习过程比喻为三个境界:
第一境界:熟用stl。
第二境界:了解泛型技术的内涵与stl的学理乃至实作。
第三境界:扩充stl。
本书无疑是你达到第二境界的最佳读本。在本书中,c++技术权威scott meyers揭示了专家总结的一些关键规则,包括他们总是采用的做法以及总是避免的做法。这些规则可以发挥stl的最大效用。
有些书只是描述stl中有些什么内容,而本书则讲述如何使用stl。本书共有50条指导原则,在讲述每一条指导原则时,scott meyers都提供了透彻的分析和深刻的实例,所以读者不仅可以学到要做什么,而且还能够知道什么时候该这样做,以及为什么要这样做。
如同meyers的其他著作一样,本书充满了从实践中总结出来的智慧。清晰、简明、透彻的风格使本书成为每一位stl程序员的案头必备。
本书特色
·关于选择容器的建议,涉及的容器有:标准stl容器(例如vector和list)、非标准的stl容器(例如hash_set和hash_map),以及非stl容器(例如bitset)。
·一些提高效率的技术,通过它们可以最大程度地提高stl(以及使用stl的程序)的效率。
·深入到迭代器、函数对象和分配子(allocator)的行为,也包括程序员总是应该避免的做法。
·对于那些同名的算法和成员函数,如find,根据它们行为方式上的微妙差异,本书给出了一些指导原则,以保证它们能被正确地使用。
·讨论了潜在的移植性问题,包括避免这些移植性问题的各种简单途径。
作译者回到顶部↑
本书提供作译者介绍
Scott Meyers 拥有布朗大学计算机科学博士学位,是世界顶级的C++软件开发技术权威之一。他的两本畅销书《Effective C++》和《More Effective C++》开创了技术图书“Effective”式的写作风格。他曾担任《C++ Report》杂志的专栏作家,还经常为《C/C++ Users Journal》和《Dr. Dobb's Journal》撰稿。
.. << 查看详细
.. << 查看详细
目录回到顶部↑
table of contents
preface xi
acknowledgments xv
introduction
chapter 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.
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.
chapter 2: vector and string
item 13: prefer vector and string to dynamically allocated arrays.
item 14: use reserve to avoid unnecessary reallocations.
preface xi
acknowledgments xv
introduction
chapter 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.
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.
chapter 2: vector and string
item 13: prefer vector and string to dynamically allocated arrays.
item 14: use reserve to avoid unnecessary reallocations.
前言回到顶部↑
自C++诞生尤其是ISO/ANSI C++标准问世以来,以Bjarne Stroustrup为首的C++社群领袖一直不遗余力地倡导采用“新风格”教学和使用C++。事实证明,除了兼容于C的低阶特性外,C++提供的高级特性以及在此基础上发展的各种惯用法可以让我们编写出更加简洁、优雅、高效、健壮的程序。.
这些高级特性和惯用法包括精致且高效的标准库和各种“准标准库”,与效率、健壮性、异常安全等主题有关的各种惯用法,以及在C++的未来占据更重要地位的模板和泛型程序设计技术等。它们发展于力量强大的C++社群,并被这个社群中最负声望的专家提炼、升华成一本本精彩的著作。毫无疑问,这些学术成果必将促进C++社群创造出更多的实践成果。
我个人认为,包括操作系统、设备驱动、编译器、系统工具、图像处理、数据库系统以及通用办公软件等在内的基础软件更能够代表一个国家的软件产业发展质量,迄今为止,此类基础性的软件恰好是C++所擅长开发的,因此,可以感性地说,C++的应用水平在一定程度上可以折射出一个国家的软件产业发展水平和健康程度。..
前些年国内曾引进出版了一大批优秀的C++书籍,它们拓宽了中国C++程序员的视野,并在很大程度上纠正了长期以来存在于C++的教育、学习和使用方面的种种误解,对C++相关的产业发展起到了一定的促进作用。然而在过去的两年中,随着.NET、Java技术吸引越来越多的注意力,中国软件产业业务化、项目化的状况愈发加剧,擅长于“系统编程”的C++语言的应用领域似有进一步缩减的趋势,这也导致人们对C++的出版教育工作失去了应有的重视。
机械工业出版社华章分社决定继续为中国C++“现代化”教育推波助澜,从2006年起将陆续推出一套“C++设计新思维”丛书。这套丛书秉持精品、高端的理念,其作译者为包括Herb Sutter在内的国内外知名C++技术专家和研究者、教育者,议题紧密围绕现代C++特性,以实用性为主,兼顾实验性和探索性,形式上则是原版影印、中文译著和原创兼收并蓄。每一本书相对独立且交叉引用,篇幅短小却内容深入。作为这套丛书的特邀技术编辑,我衷心希望它们所展示的技术、技巧和理念能够为中国C++社群注入新的活力。...
荣耀
2005年12月
南京师范大学
www.royaloo.com
It came without ribbons! It came without tags! .
It came without packages, boxes or bags!
Dr. Seuss, How the Grinch Stole Christmas!, Random House, 1957
I first wrote about the Standard Template Library in 1995, when I concluded the final Item of More Effective C++ with a brief STL overview. I should have known better. Shortly thereafter, I began receiving marl asking when I'd write Effective STL.
I resisted the idea for several years. At first, I wasn't familiar enough with the STL to offer advice on it, but as time went on and my experience with it grew, this concern gave way to other reservations. There was never any question that the library represented a breakthrough in efficient and extensible design, but when it came to using the STL, there were practical problems I couldn't overlook. Porting all but the simplest STL programs was a challenge, not only because library implementations varied, but also because template support in the underlying compilers ranged from good to awful. STL tutorials were hard to come by, so learning "the STL way of programming" was difficult, and once that hurdle was overcome, finding comprehensible and accurate reference documentation was a challenge. Perhaps most daunting, even the smallest STL usage error often led to a blizzard of compfier diagnostics, each thousands of characters long, most referring to classes, functions, or templates not mentioned in the offending source code, almost all incomprehensible. Though I had great admiration for the STL and for the people behind it, I felt uncomfortable recommending it to practicing programmers. I wasn't sure it was possible to use the STL effectively.
Then I began to notice something that took me by surprise. Despite the portability problems, despite the dismal documentation, despite the compiler diagnostics resembling transmission line noise, many of my consulting clients were using the STL anyway, Furthermore, they weren't Just playing with it, they were using it in production code! That was a revelation. I knew that the STL featured an elegant design, but any library for which prograrmners are willing to endure portabll-headaches, poor documentation, and incomprehensible error messages has a lot more going for it than just good design. For an increasingly large number of professional programmers, I realized, even a bad implementation of the ST[, was preferable to no implementation at all.
Furthermore, I knew that the situation regarding the STL would only get better. Libraries and compfiers would grow more conformant with the Standard (they have), better documentation would become avafiable (it has — consult the bibliography beginning on page 225), and compfier diagnostics would improve (for the most part, we're still waiting, but Item 49. offers suggestions for how to cope whfie we wait). I therefore decided to chip in and do my part for the STL movement. This book is the result: 50 specific ways to improve your use of C++'s Standard Template Library.
My original plan was to write the book in the second half of 1999, and with that thought in mind, I put together an outline. But then I changed course. I suspended work on the book and developed an introductory training course on the STL, which I then taught several times to groups of programmers. About a year later, I returned to the book, significanfiy revising the outline based on my experiences with the training course. In the same way that my Effective C++ has been Successful by being grounded in the problems faced by real programmers, it's my hope that Effective STL similarly addresses the practical aspects of STL programming m the aspects most important to professional developers.
I am always on the lookout for ways to improve my understanding of C++. If you have suggestions for new guidelines for STL programming or if you have comments on the guidelines in this book, please let me know. In addition, it is my'continuing goal to makethis book as accurate as possible, so for each error in this book that is reported to me be it technical, grammatical, typographical, or otherwise — I will, in future printings, gladly add to the acknowledgments the name of the first person to bring that error to my attention. Send your suggeste dguide!tries, your comments, and your criticisms to estl@aristeia.com.
I maintain a list of changes to this book Since its first printing, including bug-fixes, clarifications, and technical updates. The list is ava/l,able at the Effective S'II, Errata web site, http://www.aristeia.com/Bookirrata/estlle-errata.html.
If you'd like to be notified when I make changes to this book, I encourage you to Join my mailing list. I use the list to make announcements likely to be of interest to people who follow my work on C++. For details, consult http://www.aristeia.com/MailingList/.
这些高级特性和惯用法包括精致且高效的标准库和各种“准标准库”,与效率、健壮性、异常安全等主题有关的各种惯用法,以及在C++的未来占据更重要地位的模板和泛型程序设计技术等。它们发展于力量强大的C++社群,并被这个社群中最负声望的专家提炼、升华成一本本精彩的著作。毫无疑问,这些学术成果必将促进C++社群创造出更多的实践成果。
我个人认为,包括操作系统、设备驱动、编译器、系统工具、图像处理、数据库系统以及通用办公软件等在内的基础软件更能够代表一个国家的软件产业发展质量,迄今为止,此类基础性的软件恰好是C++所擅长开发的,因此,可以感性地说,C++的应用水平在一定程度上可以折射出一个国家的软件产业发展水平和健康程度。..
前些年国内曾引进出版了一大批优秀的C++书籍,它们拓宽了中国C++程序员的视野,并在很大程度上纠正了长期以来存在于C++的教育、学习和使用方面的种种误解,对C++相关的产业发展起到了一定的促进作用。然而在过去的两年中,随着.NET、Java技术吸引越来越多的注意力,中国软件产业业务化、项目化的状况愈发加剧,擅长于“系统编程”的C++语言的应用领域似有进一步缩减的趋势,这也导致人们对C++的出版教育工作失去了应有的重视。
机械工业出版社华章分社决定继续为中国C++“现代化”教育推波助澜,从2006年起将陆续推出一套“C++设计新思维”丛书。这套丛书秉持精品、高端的理念,其作译者为包括Herb Sutter在内的国内外知名C++技术专家和研究者、教育者,议题紧密围绕现代C++特性,以实用性为主,兼顾实验性和探索性,形式上则是原版影印、中文译著和原创兼收并蓄。每一本书相对独立且交叉引用,篇幅短小却内容深入。作为这套丛书的特邀技术编辑,我衷心希望它们所展示的技术、技巧和理念能够为中国C++社群注入新的活力。...
荣耀
2005年12月
南京师范大学
www.royaloo.com
It came without ribbons! It came without tags! .
It came without packages, boxes or bags!
Dr. Seuss, How the Grinch Stole Christmas!, Random House, 1957
I first wrote about the Standard Template Library in 1995, when I concluded the final Item of More Effective C++ with a brief STL overview. I should have known better. Shortly thereafter, I began receiving marl asking when I'd write Effective STL.
I resisted the idea for several years. At first, I wasn't familiar enough with the STL to offer advice on it, but as time went on and my experience with it grew, this concern gave way to other reservations. There was never any question that the library represented a breakthrough in efficient and extensible design, but when it came to using the STL, there were practical problems I couldn't overlook. Porting all but the simplest STL programs was a challenge, not only because library implementations varied, but also because template support in the underlying compilers ranged from good to awful. STL tutorials were hard to come by, so learning "the STL way of programming" was difficult, and once that hurdle was overcome, finding comprehensible and accurate reference documentation was a challenge. Perhaps most daunting, even the smallest STL usage error often led to a blizzard of compfier diagnostics, each thousands of characters long, most referring to classes, functions, or templates not mentioned in the offending source code, almost all incomprehensible. Though I had great admiration for the STL and for the people behind it, I felt uncomfortable recommending it to practicing programmers. I wasn't sure it was possible to use the STL effectively.
Then I began to notice something that took me by surprise. Despite the portability problems, despite the dismal documentation, despite the compiler diagnostics resembling transmission line noise, many of my consulting clients were using the STL anyway, Furthermore, they weren't Just playing with it, they were using it in production code! That was a revelation. I knew that the STL featured an elegant design, but any library for which prograrmners are willing to endure portabll-headaches, poor documentation, and incomprehensible error messages has a lot more going for it than just good design. For an increasingly large number of professional programmers, I realized, even a bad implementation of the ST[, was preferable to no implementation at all.
Furthermore, I knew that the situation regarding the STL would only get better. Libraries and compfiers would grow more conformant with the Standard (they have), better documentation would become avafiable (it has — consult the bibliography beginning on page 225), and compfier diagnostics would improve (for the most part, we're still waiting, but Item 49. offers suggestions for how to cope whfie we wait). I therefore decided to chip in and do my part for the STL movement. This book is the result: 50 specific ways to improve your use of C++'s Standard Template Library.
My original plan was to write the book in the second half of 1999, and with that thought in mind, I put together an outline. But then I changed course. I suspended work on the book and developed an introductory training course on the STL, which I then taught several times to groups of programmers. About a year later, I returned to the book, significanfiy revising the outline based on my experiences with the training course. In the same way that my Effective C++ has been Successful by being grounded in the problems faced by real programmers, it's my hope that Effective STL similarly addresses the practical aspects of STL programming m the aspects most important to professional developers.
I am always on the lookout for ways to improve my understanding of C++. If you have suggestions for new guidelines for STL programming or if you have comments on the guidelines in this book, please let me know. In addition, it is my'continuing goal to makethis book as accurate as possible, so for each error in this book that is reported to me be it technical, grammatical, typographical, or otherwise — I will, in future printings, gladly add to the acknowledgments the name of the first person to bring that error to my attention. Send your suggeste dguide!tries, your comments, and your criticisms to estl@aristeia.com.
I maintain a list of changes to this book Since its first printing, including bug-fixes, clarifications, and technical updates. The list is ava/l,able at the Effective S'II, Errata web site, http://www.aristeia.com/Bookirrata/estlle-errata.html.
If you'd like to be notified when I make changes to this book, I encourage you to Join my mailing list. I use the list to make announcements likely to be of interest to people who follow my work on C++. For details, consult http://www.aristeia.com/MailingList/.
相关资源回到顶部↑
· 【推荐】众多高校学子口口相传,他们共同的选择--华清远见嵌入式学院(嵌入式Linux就业课程、3G手机开发就业课程,通过入学测试即签100%就业协议,4个月集中实训,世界500强企业成功就业保障!!!)· 【亚嵌教育 嵌入式培训专家】(嵌入式培训,嵌入式Linux培训,ARM培训,Linux培训,3G培训,Android培训,WINCE培训,DSP培训,FPGA培训,嵌入式就业培训)
· 程序员的7种武器(正则表达式、编程语言、数据库、算法、软件调试、开发环境)
· C/C++ 经典著作(《C专家编程》《C++ Templates中文版》《C和指针 》《C陷阱与缺陷》《C++沉思录》)







点击看大图







加载中...
