Monthly Read Posts in Jun 2018
Programming Language
CppCon 2015: Richard Powell “Intro to the C++ Object Model”
基本覆盖了 POD,无需函数类,单继承的情况,扫盲效果俱佳。
至于为什么没有包含 multiple inheritance / virtual inheritance,作者说自己不是很 condifent with that。
讲道理,MI / VI 在一般的设计里都会尽量避免,而且各种乱七八糟的 case 很多,这里不涉及反而是个正确的做法。
首先,我很赞同文中作者对于 assertion 是 guarantees given by the author of a piece of code to himself/herself 但是接下来的大部观点都不赞同。
比如作者认为不应该 assert on precodintions & postconditions,因为 assertion 是 for implementation details,这个思路其实不对。
关于 assertion,目前看过最好的阐述还是 Writing Solid Code,推荐去阅读这个。
这篇 post 展示了 constexpr functions 错误报告的常见手段:抛异常。
这个在之前的某个 cppcon talk 里有专门的介绍。
另外,文中更进一步,抽出专门的 constexpr validation functions,并通过 comma operator 串联。
C++ 14 支持多句之后,连 comma operatos 都可以免掉了。