[EMCpp]Item-17 Understand Special Member Function Generation
· ☕ 2 min read
The special member functions are those ccompilers may generate on their own: default constructor, destructor, copy operations, and move operations.
The special member functions are those ccompilers may generate on their own: default constructor, destructor, copy operations, and move operations.
Make const
member functions thread safe unless we’re certain they’ll never be used in a concurrent context.
constexpr
objects are const
and are initialized with values known during compilation; constexpr
functions can produce copmile-time results when called with arguments whose values are know during compilations.
Most functions are exception-neutral, but for some, such as move operations, swap, memory deallocation functions, and destructors, noexcept
is particularly valuable.
In maximally generic code, prefer non-member versions of begin
, end
, rbegin
, etc., over their member function counterparts.