aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/winapi/buffer.hpp
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-04 23:00:02 +0200
committerEgor Tensin <egor@tensin.name>2026-06-04 23:00:02 +0200
commit3333f7cc6e5bee683ae7349ed86304e20db5a675 (patch)
tree81d2d574b9a21af6f9e56325fba8dc418ad7b3e3 /include/winapi/buffer.hpp
parentupgrade to std::optional (diff)
downloadwinapi-common-3333f7cc6e5bee683ae7349ed86304e20db5a675.tar.gz
winapi-common-3333f7cc6e5bee683ae7349ed86304e20db5a675.zip
upgrade to std::format
Diffstat (limited to 'include/winapi/buffer.hpp')
-rw-r--r--include/winapi/buffer.hpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/include/winapi/buffer.hpp b/include/winapi/buffer.hpp
index bebd05f..1009ebb 100644
--- a/include/winapi/buffer.hpp
+++ b/include/winapi/buffer.hpp
@@ -7,8 +7,8 @@
#include <cstddef>
#include <cstring>
+#include <format>
#include <initializer_list>
-#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
@@ -67,11 +67,8 @@ public:
std::wstring as_utf16() const {
const auto c_str = reinterpret_cast<const wchar_t*>(data());
const auto nb = size();
- if (nb % 2 != 0) {
- std::ostringstream oss;
- oss << "Buffer size invalid at " << nb << " bytes";
- throw std::runtime_error{oss.str()};
- }
+ if (nb % 2 != 0)
+ throw std::runtime_error{std::format("Buffer size invalid at {} bytes", nb)};
const auto nch = nb / 2;
return {c_str, nch};
}