gol*_*ode 3 c++ idioms c++11 rule-of-zero
我正在研究零度规则,并且对最终的一段代码有两个问题,这些代码证明了规则.
class module {
public:
explicit module(std::wstring const& name)
: handle { ::LoadLibrary(name.c_str()), &::FreeLibrary } {}
// other module related functions go here
private:
using module_handle = std::unique_ptr<void, decltype(&::FreeLibrary)>;
module_handle handle;
};
Run Code Online (Sandbox Code Playgroud)