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