#pragma once #include #include #include #include #include #include #include "concept.h" #include "platform/detail.h" #include "memory/resource.h" namespace ipc { namespace detail { struct has_value_type_ { template static std::true_type check(typename T::value_type *); template static std::false_type check(...); }; template (nullptr))> struct is_same_char : std::is_same {}; template struct is_same_char : std::is_same {}; template using IsSameChar = ipc::require::value, R>; //////////////////////////////////////////////////////////////// /// to_tchar implementation //////////////////////////////////////////////////////////////// template constexpr auto to_tchar(ipc::string && str) -> IsSameChar { return std::move(str); } template constexpr auto to_tchar(ipc::string && str) -> IsSameChar { return std::wstring_convert< std::codecvt_utf8_utf16, wchar_t, ipc::mem::allocator, ipc::mem::allocator >{}.from_bytes(std::move(str)); } template inline auto to_tchar(T* dst, char const * src, std::size_t size) -> IsSameChar { std::memcpy(dst, src, size); } template inline auto to_tchar(T* dst, char const * src, std::size_t size) -> IsSameChar { auto wstr = std::wstring_convert< std::codecvt_utf8_utf16, wchar_t, ipc::mem::allocator, ipc::mem::allocator >{}.from_bytes(src, src + size); std::memcpy(dst, wstr.data(), (ipc::detail::min)(wstr.size(), size)); } } // namespace detail } // namespace ipc