Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC++rule of 5 and rule of 0Single-choice MCQ

Under the rule of 5, why is a hand-written `= default` move constructor still preferable to writing the moves by hand for a class whose members are all RAII types?

struct Session { std::unique_ptr<Conn> conn; std::vector<Msg> backlog; // user-declared destructor below forces us to also restore moves ~Session() { /* log teardown */ } Session(Session&&) = default; Session& operator=(Session&&) = default; };