@@ -52,13 +52,13 @@ class BufferSpan
52
52
_T* get (ULONG idx = 0 ) const
53
53
{
54
54
if (idx >= m_Elts)
55
- throw Exception (Severity::Fatal, E_INVALIDARG, L" Invalid index acces into BufferExView" sv);
55
+ throw Exception (Severity::Fatal, E_INVALIDARG, L" Invalid index access into BufferExView" sv);
56
56
return &m_Ptr[idx];
57
57
}
58
58
const _T& operator [](ULONG idx) const
59
59
{
60
60
if (idx >= m_Elts)
61
- throw Exception (Severity::Fatal, E_INVALIDARG, L" Invalid index acces into BufferExView" sv);
61
+ throw Exception (Severity::Fatal, E_INVALIDARG, L" Invalid index access into BufferExView" sv);
62
62
return m_Ptr[idx];
63
63
}
64
64
@@ -80,6 +80,16 @@ class BufferSpan
80
80
return reinterpret_cast <_T_as*>(ptr) + nth;
81
81
}
82
82
83
+ void zero (_In_ const std::optional<ULONG> pos = std::nullopt, _In_ std::optional<ULONG> Elts = std::nullopt)
84
+ {
85
+ auto size_ = size ();
86
+ auto position = pos.value_or (0LU);
87
+ if (position >= size_)
88
+ return ;
89
+ auto elements = Elts.value_or (size_ - position);
90
+ ZeroMemory (get (position), std::min (size_ - position, elements) * sizeof (_T));
91
+ }
92
+
83
93
private:
84
94
_T* m_Ptr;
85
95
ULONG m_Elts;
@@ -567,9 +577,9 @@ class Buffer
567
577
{
568
578
auto size_ = size ();
569
579
auto position = pos.value_or (0LU);
570
- auto elements = Elts.value_or (size_ - position);
571
- if (pos >= size_)
580
+ if (position >= size_)
572
581
return ;
582
+ auto elements = Elts.value_or (size_ - position);
573
583
ZeroMemory (get (position), std::min (size_ - position, elements) * sizeof (_T));
574
584
}
575
585
@@ -711,15 +721,15 @@ class Buffer
711
721
_T* get_raw (ULONG index = 0 ) const
712
722
{
713
723
return std::visit (
714
- [index ](auto && arg) -> auto { return arg.get (index ); }, m_store);
724
+ [index ](auto && arg) -> auto { return arg.get (index ); }, m_store);
715
725
}
716
726
717
727
explicit operator _T*(void ) const { return get (); }
718
728
719
729
bool owns (void ) const
720
730
{
721
731
return std::visit (
722
- [](auto && arg) -> auto { return arg.owns (); }, m_store);
732
+ [](auto && arg) -> auto { return arg.owns (); }, m_store);
723
733
}
724
734
725
735
template <typename _TT>
0 commit comments