Passing around std::vector
by value now doesn't create temporary copies, without the return value optimization.
Scott: Understand std::move
and std::forward
Herb: Use return-by-value way more often
Scott, Andrei & Herb: Overuse of std::move
and references vs. values
Panel: When to use && parameters?
Panel: The magic of template <typename T> f(T&&)
Stephan: Mistakes with rvalue references
Investigate: In which cases does having a move constructor and move assignment operator help performance?
Bitwise/physical constness vs logical constness. The advice in EC++ item 3 is "Compilers enforce bitwise constness, but you should program using logical constness."
Scott: Make const
member functions thread-safe
Andrei, Scott & Herb: Use const
to mean thread-safe?
Investigate: Any effects on generated code? Common sub-expression elimination.
???
Panel: expanding constexpr
Scott: Distinguish ()
and {}
when creating objects
std::unique_ptr
and std::shared_ptr
Herb: Use smart pointers effectively ... but still use lots of raw * and &
Interactive Panel: Reference cycles with std::shared_ptr
(STL quote: "Ownership is a directed acyclic graph.")
for (auto& element : elements) element->setCurrentTime(0);
Herb: Prefer range-for
Herb Sutter says use it wherever possible. Good idea?
Scott: Prefer auto
to explicit type declarations
Herb: Let's talk about auto
Andrei, Scott & Herb: When to use the auto
keyword?
Scott's C++ Type Deduction and Why You Care: NDC 2014 & CppCon 2014
Investigate!
Scott: Declare functions noexcept
whenever possible
Andrei, Scott & Herb: Use exceptions?
template <typename T> T add(const T& a, const T& b) { return a + b; }
Investigate: interaction with exceptions.
std::async
is cool.
Scott: Make std::thread
s unjoinable on all paths
Andrei, Scott & Herb: std::async
Andrei, Scott & Herb: std::thread
Always use it?
Can do it with std::tuple
and std::tie
.
Herb: forward declare Widget
and Gadget
when declaring Widget f(Gadget);
Google C++: Use int
or a precise type from stdint.h
Panel: Use int
, avoid unsigned
Panel: More on unsigned