(C++) Letting `unique_ptr` have `nullptr` value

Setting a unique_ptr to nullptr is supported by C++11 standard.

  1. Declaring a unique_ptr without definition fills the pointer with nullptr

  2. unique_ptr has dedicated overloaded assignment operator to update its value

    • The object previously pointed to by the pointer is destroyed
    • Effectively equivalent to unique_ptr::reset() with no argument

References:

Written on March 9, 2021