From 25f39c16c2024bd7c9e03b4bc84625d0c8eed849 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 18 Oct 2020 02:38:23 +0300 Subject: much more type-safe & generic overloads --- include/winapi/utf8.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include/winapi') diff --git a/include/winapi/utf8.hpp b/include/winapi/utf8.hpp index c6fc77b..9469fd7 100644 --- a/include/winapi/utf8.hpp +++ b/include/winapi/utf8.hpp @@ -6,18 +6,26 @@ #pragma once #include +#include #include #include namespace winapi { std::wstring widen(const std::string&); -std::wstring widen(const std::vector&); std::wstring widen(const void*, std::size_t nb); +template > +std::wstring widen(const std::vector& src) { + return widen(src.data(), src.size() * sizeof(T)); +} + std::string narrow(const std::wstring&); -std::string narrow(const wchar_t*, std::size_t nch); -std::string narrow(const std::vector&); std::string narrow(const void*, std::size_t nb); +template > +std::string narrow(const std::vector& src) { + return narrow(src.data(), src.size() * sizeof(T)); +} + } // namespace winapi -- cgit v1.2.3