#ifndef WCHARPTR_H #define WCHARPTR_H #include /* WcharPtr: Simple wrapper for wide C strings. */ struct WcharPtr { /* Named copy constructors (expensive). */ static WcharPtr FromNarrow(const char* buf, int cp = CP_UTF8); static WcharPtr Copy(const wchar_t* s); /* Non-explicit copies are disabled. */ WcharPtr(WcharPtr& other) = delete; WcharPtr& operator=(WcharPtr& other) = delete; WcharPtr() noexcept; ~WcharPtr(); operator wchar_t*() noexcept; WcharPtr(wchar_t* s) noexcept; WcharPtr& operator=(wchar_t* s) noexcept; WcharPtr(WcharPtr&& other) noexcept; WcharPtr& operator=(WcharPtr&& other) noexcept; /* Return pointer, releasing ownership. */ wchar_t *Release() noexcept; private: wchar_t* m_p = nullptr; }; #endif