diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-04 22:39:44 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-04 22:42:12 +0200 |
| commit | 7fcbd6e474235957f2785c3d9b5344b2acf3ff77 (patch) | |
| tree | 4c1a2d5971a9db5330963ac7d77501638efeb4c0 /include/winapi/handle.hpp | |
| parent | upgrade to `using` instead of typedef (diff) | |
| download | winapi-common-7fcbd6e474235957f2785c3d9b5344b2acf3ff77.tar.gz winapi-common-7fcbd6e474235957f2785c3d9b5344b2acf3ff77.zip | |
upgrade to std::string_view
Diffstat (limited to 'include/winapi/handle.hpp')
| -rw-r--r-- | include/winapi/handle.hpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/include/winapi/handle.hpp b/include/winapi/handle.hpp index b5a7547..7af7252 100644 --- a/include/winapi/handle.hpp +++ b/include/winapi/handle.hpp @@ -11,7 +11,7 @@ #include <cstddef> #include <memory> -#include <string> +#include <string_view> #include <utility> namespace winapi { @@ -69,14 +69,23 @@ public: * @param buffer Binary data to write. */ void write(const Buffer& buffer) const; - /** * Write data to this handle. * @param src Binary data to write. */ template <typename CharT> - void write(const std::basic_string<CharT>& src) const { - write(src.c_str(), src.size() * sizeof(CharT)); + void write(std::basic_string_view<CharT> src) const { + write(src.data(), src.length() * sizeof(CharT)); + } + /** + * Write data to this handle. + * @param src Binary data to write. + */ + template <typename CharT, + typename Traits = std::char_traits<CharT>, + typename Allocator = std::allocator<CharT>> + void write(const std::basic_string<CharT, Traits, Allocator> src) const { + write(std::basic_string_view<CharT>{src}); } void inherit(bool yes = true) const; |
