是有效的C ++仍然有效吗? [英] Is effective C++ still effective?

查看:200
本文介绍了是有效的C ++仍然有效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我在这篇文章中看到的内容,我决定开始阅读此书有效的C ++

From what I saw in this post I decided to start reading the book Effective C++.

但现在有很多新的功能,因为C ++ 11和一些好的做法改变,我不知道它是否是一个好主意。 C ++ 11的出现是否废弃了Effective C ++中包含的任何建议?

But now that there are many new features because of C++11 and that a few of the good practices changed, I'm not sure whether or not it is actually a good idea. Has the advent of C++11 deprecated any of the advice contained in Effective C++? If so, which topics should I avoid?

推荐答案

这是Scott Meyers自己不得不说的话在自己的博客

This what Scott Meyers himself had to say about it on his own blog


这可能会让你想知道
中的信息和建议是否有效C ++的C ++ 0x版本仍然是相关的。我很高兴
报告它。令人惊讶的是,事实上。花了近
两年沉浸在C ++ 0x的细节,我预计会呻吟一点
,因为我考虑了本书的目录与C ++ 0x。当然
一些项目是不合适的。但是我发现的建议证明了
的声音。 C ++ 0x开发者喜欢const,枚举和内联到
#defines (Item 2)?他们应该。是否应该阻止
中的异常留下析构函数(第8项)?当然。他们应该使用对象
管理资源吗?声明数据成员是私有的?考虑替代
到虚函数?因子与
模板中的参数无关的代码? (项目13,22,35和44.)是,是的,是的,是的!我的目标有
总是为有效C ++的目录总结本书中的
建议,并且该汇总仍然适用于
C ++ 0x开发为传统的C +发展。 C ++ 0x是一个
更大的语言,在某些方面是一个不同的,但核心
技术有效地使用老C ++是核心的
有效使用C ++ 0x。

Which may lead you to wonder whether the information and advice in this pre-C++0x edition of Effective C++ remains relevant. I'm pleased to report that it does. Surprisingly so, in fact. Having spent nearly two years steeped in the details of C++0x, I expected to groan a bit as I reviewed this book's table of contents with C++0x in mind. Surely some Items would be inappropriate. But the advice I found proved sound. Should C++0x developers prefer consts, enums, and inlines to #defines (Item 2)? They should. Should they prevent exceptions from leaving destructors (Item 8)? Certainly. Should they use objects to manage resources? Declare data members private? Consider alternatives to virtual functions? Factor parameter-independent code out of templates? (Items 13, 22, 35, and 44.) Yes, yes, yes, yes! My goal has always been for Effective C++'s table of contents to summarize the advice in the book, and that summary remains just as applicable to C++0x development as to "traditional" C++ development. C++0x is a bigger language, and in some ways it's a different one, but the core techniques for making effective use of "old" C++ are core for the effective use of C++0x, too.

这并不意味着Effective C ++是一个完美的匹配
C ++ 0x。本书没有讨论C ++ 0x的新特性,因此缺少有关使用这些特性的
项目。一个C ++ 0xified
有效的C ++肯定有Items用于移动操作,
用于统一的初始化和lambda表达式,它可能有一个整章有效地使用并发API 。这样的书还将包含不同的示例,例如,使用自动变量,基于范围的for循环,类内默认初始化器,以及偶尔的可变参数模板。在这本书缺乏对C ++ 0x支持的程度上,错误是那些遗漏,而不是佣金。

This doesn't mean that this Effective C++ is a perfect match for C++0x. The book doesn't discuss features new to C++0x, so Items about making effective use of those features are missing. A C++0xified Effective C++ would certainly have Items devoted to move operations, to uniform initialization, and to lambda expressions, and it'd probably have an entire chapter on making effective use of the concurrency API. Such a book would also contain different examples, e.g., ones making use of auto variables, range-based for loops, in-class default initializers, as well as the occasional variadic template. To the extent that this book falls short in its support for C++0x, the errors are those of omission, not commission.

UPDATE :新标题有效现代C ++ 自2014年11月起从 O'Reilly 亚马逊 (和许多其他您可以google的)。

UPDATE: the new title Effective Modern C++ has been for sale since November 2014 from O'Reilly and Amazon (and many others that you can google for).

这篇关于是有效的C ++仍然有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆