forked from mutouyun/nixy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvector.h
85 lines (68 loc) · 2.12 KB
/
vector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
The Nixy Library
Code covered by the MIT License
Author: mutouyun (http://darkc.at)
*/
#pragma once
#include "nixycore/memory/default_alloc.h"
#include "nixycore/utility/rvalue.h"
#include "nixycore/general/general.h"
#include <vector> // std::vector
//////////////////////////////////////////////////////////////////////////
NX_BEG
//////////////////////////////////////////////////////////////////////////
#ifdef NX_SP_CXX11_ALIAS
template <typename T, class AllocT = NX_DEFAULT_ALLOC>
using vector = std::vector<T, typename AllocT::template std_allocator<T>::type_t>;
#else /*NX_SP_CXX11_ALIAS*/
template <typename T, class AllocT = NX_DEFAULT_ALLOC>
class vector : public std::vector<T, typename AllocT::template std_allocator<T>::type_t>
{
typedef std::vector<T, typename AllocT::template std_allocator<T>::type_t> base_t;
public:
#ifdef NX_SP_CXX11_INHERITING
using base_t::vector;
#else /*NX_SP_CXX11_INHERITING*/
vector(void)
: base_t()
{}
explicit vector(const typename base_t::allocator_type& a)
: base_t(a)
{}
explicit vector(typename base_t::size_type n,
const typename base_t::value_type& v = typename base_t::value_type(),
const typename base_t::allocator_type& a = typename base_t::allocator_type())
: base_t(n, v, a)
{}
template <typename IteratorT>
vector(IteratorT f, IteratorT l,
const typename base_t::allocator_type& a = typename base_t::allocator_type())
: base_t(f, l, a)
{}
vector(const vector& rhs)
: base_t(rhs)
{}
vector(nx_rref(vector, true) rhs)
: base_t()
{
base_t::swap(moved(rhs));
}
#endif/*NX_SP_CXX11_INHERITING*/
vector& operator=(vector rhs)
{
rhs.swap(*this);
return (*this);
}
};
/*
Special swap algorithm
*/
template <typename T_, class A_>
inline void swap(vector<T_, A_>& x, vector<T_, A_>& y)
{
x.swap(y);
}
#endif/*NX_SP_CXX11_ALIAS*/
//////////////////////////////////////////////////////////////////////////
NX_END
//////////////////////////////////////////////////////////////////////////