An interesting question, with a proposed answer:
Declaring the move constructor
by Andrzej Krzemieński
From the article:
I am not satisfied with the solution I gave in the previous post. The proposed interface was this:
class Tool { private: ResourceA resA_; ResourceB resB_; // more resources public: // Tools's interface Tool(Tool &&) = default; // noexcept is deduced Tool& operator=(Tool&&) = default; // noexcept is deduced Tool(Tool const&) = delete; Tool& operator=(Tool const&) = delete; }; static_assert(std::is_move_constructible<Tool>::value, "..."); static_assert(std::is_move_assignable<Tool>::value, "...");In a way, it is self contradictory. The whole idea behind departing from the Rule of Zero is to separate the interface from the current implementation. Yet, as the comments indicate, the exception specification is deduced from the current implementation, and thus unstable...
Add a Comment
Comments are closed.