[vbox-dev] Fix vector::data() methods and add vector::clear()
Martin Fleisz
martin.fleisz at thincast.com
Wed Dec 28 14:04:17 GMT 2022
The patch below fixes a compilation issue when using vector::data() and
adds a clear() method to the template.
I'm submitting this patch under the MIT license.
Best regards and a happy new year!
Martin Fleisz
Thincast Technologies GmbH
Bahnhofplatz 7/3, 2340 Moedling, Austria
http://www.thincast.com
diff --git include/iprt/nocrt/vector include/iprt/nocrt/vector
index 925f9e1ac18..e5ed2c4f4ce 100644
--- include/iprt/nocrt/vector
+++ include/iprt/nocrt/vector
@@ -228,15 +228,7 @@ namespace std
~vector()
{
- size_type i = m_cItems;
- while (i-- > 0)
- {
- m_Allocator.destroy(&m_paItems[i]);
- m_cItems = i;
- }
- m_Allocator.deallocate(m_paItems, m_cAllocated);
- m_paItems = NULL;
- m_cAllocated = 0;
+ clear();
}
@@ -309,12 +301,12 @@ namespace std
pointer data() RT_NOEXCEPT
{
- return m_paItem;
+ return m_paItems;
}
const_pointer data() const RT_NOEXCEPT
{
- return m_paItem;
+ return m_paItems;
}
/** @} */
@@ -385,6 +377,19 @@ namespace std
if (m_cItems > 0)
m_cItems -= 1;
}
+
+ void clear() RT_NOEXCEPT
+ {
+ size_type i = m_cItems;
+ while (i-- > 0)
+ {
+ m_Allocator.destroy(&m_paItems[i]);
+ m_cItems = i;
+ }
+ m_Allocator.deallocate(m_paItems, m_cAllocated);
+ m_paItems = NULL;
+ m_cAllocated = 0;
+ }
/** @} */
};
More information about the vbox-dev
mailing list