Skip to content

Commit 0fb4e97

Browse files
committed
Use std::copy_n instead of std::memcpy, and protect std::numeric_limits<T>::max from the max macro
1 parent c4c553d commit 0fb4e97

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cppwinrt/cmd_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ namespace cppwinrt
314314
struct option
315315
{
316316
static constexpr std::uint32_t no_min = 0;
317-
static constexpr std::uint32_t no_max = std::numeric_limits<std::uint32_t>::max();
317+
static constexpr std::uint32_t no_max = (std::numeric_limits<std::uint32_t>::max)();
318318

319319
std::string_view name;
320320
std::uint32_t min{ no_min };

strings/base_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ namespace winrt::impl
105105
}
106106

107107
auto header = precreate_hstring_on_heap(length);
108-
std::memcpy(header->buffer, value, sizeof(wchar_t) * length);
108+
std::copy_n(value, length, header->buffer);
109109
return header;
110110
}
111111

strings/base_string_operators.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ namespace winrt::impl
104104
return{};
105105
}
106106
hstring_builder text(size);
107-
std::memcpy(text.data(), left.data(), left.size() * sizeof(wchar_t));
108-
std::memcpy(text.data() + left.size(), right.data(), right.size() * sizeof(wchar_t));
107+
std::copy_n(left.data(), left.size(), text.data());
108+
std::copy_n(right.data(), right.size(), text.data() + left.size());
109109
return text.to_hstring();
110110
}
111111
}

0 commit comments

Comments
 (0)