Skip to content

Commit 5a3b1e4

Browse files
tamlin-mikeXottab-DUTY
authored andcommitted
Make xr_vector.h self-contained.
1 parent c31426e commit 5a3b1e4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/xrCommon/xr_vector.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include <vector>
33
#include "xalloc.h"
4+
#include "xrCore/xrDebug_macros.h"
45

56
#ifdef _M_AMD64
67
#define M_DONTDEFERCLEAR_EXT
@@ -30,9 +31,9 @@ class xr_vector : public std::vector<T, allocator>
3031
xr_vector() : inherited() {}
3132
xr_vector(size_t _count, const T& _value) : inherited(_count, _value) {}
3233
explicit xr_vector(size_t _count) : inherited(_count) {}
33-
u32 size() const { return (u32)inherited::size(); }
34+
u32 size() const throw() { return (u32)inherited::size(); }
3435

35-
void clear_and_free() { inherited::clear(); }
36+
void clear_and_free() throw() { inherited::clear(); }
3637
void clear_not_free() { erase(begin(), end()); }
3738
void clear_and_reserve()
3839
{
@@ -52,16 +53,22 @@ class xr_vector : public std::vector<T, allocator>
5253
#endif
5354
const_reference operator[](size_type _Pos) const
5455
{
55-
VERIFY2(_Pos<size(),
56-
make_string("index is out of range: index requested[%d], size of container[%d]", _Pos, size()).c_str());
56+
check_idx(_Pos);
5757
return *(begin()+_Pos);
5858
}
5959
reference operator[](size_type _Pos)
6060
{
61-
VERIFY2(_Pos<size(),
62-
make_string("index is out of range: index requested[%d], size of container[%d]", _Pos, size()).c_str());
61+
check_idx(_Pos);
6362
return *(begin()+_Pos);
6463
}
64+
65+
private:
66+
void check_idx(size_type _Pos) const
67+
{
68+
VERIFY2(_Pos < size(),
69+
make_string("index is out of range: index requested[%d], size of container[%d]",
70+
_Pos, size()).c_str());
71+
}
6572
};
6673

6774
// vector<bool>

0 commit comments

Comments
 (0)