Reading Notes of 《Effective Modern C++》

Abstract

《Effective Modern C++》is written by Scott Meyers, and translated to Chinese version by 高博 and published in 2018.

This book recorded 42 skills or tips abour modern c++(c++11&c++14). It’s not a book that show you how to program with c++ from scratch. Instead, it shows you some traps you may never know when you study in school. Those are summarized from real experience or lessons. it worth reading to save you time to avoid/handle such traps.

Content

Tip34: choose lambda other than std::bind

std::bind is from c++98. as a old tool, it benefit when you want to bind some parameters to a function and return as a new function. std::bind won’t require you to specify the parameters’ types, as it use placeholder to set any type of variables.

因为在C++11中,相对于std::bind, lambda几乎总会是更好的选择, 到了C++14,lambda不仅是优势变强,简直已成为不二之选。

以上论断主要有两个原因,第一个是lambda的可读性比用placeholder来实现的std::bind好得多。 第二个原因是lambda的性能通常也会比std::bind更好。

std::bind的一个特点是它可以不指定类型,因为是用占位符placeholder来表示的。

Questions

History

  • 2023-01-05: start this post and take note of Tip34.