Verdict: Highly recommended
The title of this book is slightly misleading. With so many books on the market, there aren’t that many snappy titles left. I would say that this is more of a General C++ Overview with an Emphasis on Performance. But I understand why Packt didn’t want something like that.
The prose is clear, I liked the layout and there are a good number of well-drawn diagrams. I barely noticed any errors.
There are 15 chapters covering the basics, data structures, algorithms, memory, templates, caching, concurrency and coroutines. That’s an awful lot to cover in only 500 pages and I think that they did a pretty good job. Some parts were a bit weak – I’ve read better explanations of threading issues.
Overall, for beginner to medium-level programmer, I’d say this is one of the better books that I’ve read, especially if performance is important for you (and it usually is for C++ developers).
Whilst examples in books like this are not meant for production code, one snippet bothered me because it was so bad. It’s part of a safe_cast supposedly checking that various types are safe to cast to each other. The bit for floating point is
else if constexpr (
is_float_to_float) {
auto casted
= static_cast<OutType>(v);
auto casted_back
= static_cast<InType>(v);
assert(!isnan(casted_back) &&
!isinf(casted_back));
return casted;
}
where is_float_to_float is true when InType and OutType are both is_floating_point_v. I’ll ignore long double.
- It’s always safe to promote
floattodouble(and this gets done all the time behind the scenes). - If floating point exceptions are enabled this will generate a SIGFPE and possibly crash if the casting results in underflow, overflow and maybe an invalid operation.
- Why
assertonnan? - Why not accept
infinput? - I still don’t see any practical use for a conversion from
doubletofloatthat is restricted todoublevalues that can be exactly represented by afloat.
Getting off my hobby horse, I still enjoyed the book a lot and took several notes that I want to go back over and test out. The authors have a github repo which will make that easier.
Website: https://www.packtpub.com/product/c-high-performance-second-edition/9781839216541










