Skip to content

Commit 4c332f6

Browse files
committed
xrCommon: alias templates instead of class inherited from std::class
Remove xalloc.h from common project (it is in xrCore project)
1 parent dff8844 commit 4c332f6

File tree

8 files changed

+36
-68
lines changed

8 files changed

+36
-68
lines changed

src/Common/Common.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@
171171
<ClInclude Include="..\xrCommon\math_funcs_inline.h" />
172172
<ClInclude Include="..\xrCommon\misc_math_types.h" />
173173
<ClInclude Include="..\xrCommon\predicates.h" />
174-
<ClInclude Include="..\xrCommon\xalloc.h" />
175174
<ClInclude Include="..\xrCommon\xr_deque.h" />
176175
<ClInclude Include="..\xrCommon\xr_list.h" />
177176
<ClInclude Include="..\xrCommon\xr_map.h" />

src/Common/Common.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
<ClInclude Include="..\xrCommon\misc_math_types.h">
5555
<Filter>xrCommon</Filter>
5656
</ClInclude>
57-
<ClInclude Include="..\xrCommon\xalloc.h">
58-
<Filter>xrCommon</Filter>
59-
</ClInclude>
6057
<ClInclude Include="..\xrCommon\xr_map.h">
6158
<Filter>xrCommon</Filter>
6259
</ClInclude>

src/xrCommon/xr_deque.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@
33
#include "xrCore/Memory/XRayAllocator.hpp"
44

55
template <typename T, typename allocator = XRay::xray_allocator<T>>
6-
class xr_deque : public std::deque<T, allocator>
7-
{
8-
public:
9-
typedef typename allocator allocator_type;
10-
typedef typename allocator_type::value_type value_type;
11-
typedef typename allocator_type::size_type size_type;
12-
13-
u32 size() const { return (u32)std::deque<T, allocator>::size(); }
14-
};
6+
using xr_deque = std::deque<T, allocator>;
157

168
#define DEF_DEQUE(N, T)\
17-
typedef xr_deque<T> N;\
18-
typedef N::iterator N##_it;
9+
using N = xr_deque<T>;\
10+
using N##_it = N::iterator;
1911

2012
#define DEFINE_DEQUE(T, N, I)\
21-
typedef xr_deque<T> N;\
22-
typedef N::iterator I;
13+
using N = xr_deque<T>;\
14+
using I = N::iterator;

src/xrCommon/xr_list.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
#include "xrCore/Memory/XRayAllocator.hpp"
44

55
template <typename T, typename allocator = XRay::xray_allocator<T>>
6-
class xr_list : public std::list<T, allocator>
7-
{
8-
public:
9-
u32 size() const { return (u32)std::list<T, allocator>::size(); }
10-
};
6+
using xr_list = std::list<T, allocator>;
117

128
#define DEF_LIST(N, T)\
13-
typedef xr_list<T> N;\
14-
typedef N::iterator N##_it;
9+
using N = xr_list<T>;\
10+
using N##_it = N::iterator;
1511

1612
#define DEFINE_LIST(T, N, I)\
17-
typedef xr_list<T> N;\
18-
typedef N::iterator I;
13+
using N = xr_list<T>;\
14+
using I = N::iterator;

src/xrCommon/xr_map.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@
33
#include "xrCore/Memory/XRayAllocator.hpp"
44

55
template <typename K, class V, class P = std::less<K>, typename allocator = XRay::xray_allocator<std::pair<K, V>>>
6-
class xr_map : public std::map<K, V, P, allocator>
7-
{
8-
public:
9-
u32 size() const { return (u32)std::map<K, V, P, allocator>::size(); }
10-
};
6+
using xr_map = std::map<K, V, P, allocator>;
117

128
template <typename K, class V, class P = std::less<K>, typename allocator = XRay::xray_allocator<std::pair<K, V>>>
13-
class xr_multimap : public std::multimap<K, V, P, allocator>
14-
{
15-
public:
16-
u32 size() const { return (u32)std::multimap<K, V, P, allocator>::size(); }
17-
};
9+
using xr_multimap = std::multimap<K, V, P, allocator>;
1810

1911
#define DEF_MAP(N, K, T)\
2012
typedef xr_map<K, T> N;\

src/xrCommon/xr_set.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,15 @@
33
#include "xrCore/Memory/XRayAllocator.hpp"
44

55
template <typename K, class P = std::less<K>, typename allocator = XRay::xray_allocator<K>>
6-
class xr_set : public std::set<K, P, allocator>
7-
{
8-
public:
9-
u32 size() const { return (u32)std::set<K, P, allocator>::size(); }
10-
};
6+
using xr_set = std::set<K, P, allocator>;
117

128
template <typename K, class P = std::less<K>, typename allocator = XRay::xray_allocator<K>>
13-
class xr_multiset : public std::multiset<K, P, allocator>
14-
{
15-
public:
16-
u32 size() const { return (u32)std::multiset<K, P, allocator>::size(); }
17-
};
9+
using xr_multiset = std::multiset<K, P, allocator>;
1810

1911
#define DEFINE_SET(T, N, I)\
20-
typedef xr_set<T> N;\
21-
typedef N::iterator I;
12+
using N = xr_set<T>;\
13+
using I = N::iterator;
2214

2315
#define DEFINE_SET_PRED(T, N, I, P)\
24-
typedef xr_set<T, P> N;\
25-
typedef N::iterator I;
16+
using N = xr_set<T, P>;\
17+
using I = N::iterator;

src/xrCommon/xr_stack.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ template <typename _Ty, class _C = xr_vector<_Ty>>
55
class xr_stack
66
{
77
public:
8-
typedef typename _C::allocator_type allocator_type;
9-
typedef typename allocator_type::value_type value_type;
10-
typedef typename allocator_type::size_type size_type;
11-
typedef xr_stack<_Ty, _C> _Myt;
8+
using allocator_type = typename _C::allocator_type;
9+
using value_type = typename allocator_type::value_type;
10+
using size_type = typename allocator_type::size_type;
11+
using _Myt = xr_stack<_Ty, _C>;
1212

1313
allocator_type get_allocator() const { return c.get_allocator(); }
1414
bool empty() const { return c.empty(); }
@@ -17,15 +17,15 @@ class xr_stack
1717
const value_type& top() const { return c.back(); }
1818
void push(const value_type& _X) { c.push_back(_X); }
1919
void pop() { c.pop_back(); }
20-
bool operator==(const _Myt& _X) const { return c==_X.c; }
21-
bool operator!=(const _Myt& _X) const { return !(*this==_X); }
22-
bool operator<(const _Myt& _X) const { return c<_X.c; }
23-
bool operator>(const _Myt& _X) const { return _X<*this; }
24-
bool operator<=(const _Myt& _X) const { return !(_X<*this); }
25-
bool operator>=(const _Myt& _X) const { return !(*this<_X); }
20+
bool operator==(const _Myt& _X) const { return c == _X.c; }
21+
bool operator!=(const _Myt& _X) const { return !(*this == _X); }
22+
bool operator<(const _Myt& _X) const { return c < _X.c; }
23+
bool operator>(const _Myt& _X) const { return _X < *this; }
24+
bool operator<=(const _Myt& _X) const { return !(_X < *this); }
25+
bool operator>=(const _Myt& _X) const { return !(*this < _X); }
2626

2727
protected:
2828
_C c;
2929
};
3030

31-
#define DEFINE_STACK(T, N) typedef xr_stack<T> N;
31+
#define DEFINE_STACK(T, N) using N = xr_stack<T>;

src/xrCommon/xr_vector.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#include <vector>
33
#include "xrCore/Memory/XRayAllocator.hpp"
44

5+
template <typename T, typename allocator = XRay::xray_allocator<T>>
6+
using xr_vector = class std::vector<T, allocator>;
7+
58
#define DEF_VECTOR(N, T)\
6-
typedef xr_vector<T> N;\
7-
typedef N::iterator N##_it;
9+
using N = xr_vector<T>;\
10+
using N##_it = N::iterator;
811

912
#define DEFINE_VECTOR(T, N, I)\
10-
typedef xr_vector<T> N;\
11-
typedef N::iterator I;
12-
13-
template <typename T, typename allocator = XRay::xray_allocator<T>>
14-
using xr_vector = class std::vector<T, allocator>;
13+
using N = xr_vector<T>;\
14+
using I = N::iterator;

0 commit comments

Comments
 (0)