[EMCpp]Item-18 Use std::unique_ptr for Exclusive-ownership Resource Management
· ☕ 3 min read
std::unique_ptr is a small, fast, move-only smart pointer for managing resources with exclusive-ownership semantics.
std::unique_ptr is a small, fast, move-only smart pointer for managing resources with exclusive-ownership semantics.
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.