1 /* ///////////////////////////////////////////////////////////////////////
7 * Brief: basic_varray class
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
13 #ifndef EXTL_MATH_BASIC_VARRAY_H
14 #define EXTL_MATH_BASIC_VARRAY_H
16 /*!\file basic_varray.h
17 * \brief basic_varray class
20 /* ///////////////////////////////////////////////////////////////////////
24 #include "..\memory\buffer.h"
25 #include "varray_base.h"
27 /* ///////////////////////////////////////////////////////////////////////
33 /*!\brief: basic_varray class
35 * \param T The element type
36 * \param B The buffer type
38 * \ingroup extl_group_math
40 template< typename_param_k T
41 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
42 , typename_param_k B
= typename_type_def_k buffer_selector
<T
>::buffer_type
48 : public varray_base
< basic_varray
<T
, B
>
53 typedef varray_base
< basic_varray
<T
, B
>
60 typedef basic_varray class_type
;
61 typedef typename_type_k
base_type::buffer_type buffer_type
;
62 typedef typename_type_k
base_type::allocator_type allocator_type
;
63 typedef typename_type_k
base_type::value_type value_type
;
64 typedef typename_type_k
base_type::pointer pointer
;
65 typedef typename_type_k
base_type::const_pointer const_pointer
;
66 typedef typename_type_k
base_type::reference reference
;
67 typedef typename_type_k
base_type::const_reference const_reference
;
68 typedef typename_type_k
base_type::iterator iterator
;
69 typedef typename_type_k
base_type::const_iterator const_iterator
;
70 typedef typename_type_k
base_type::reverse_iterator reverse_iterator
;
71 typedef typename_type_k
base_type::const_reverse_iterator const_reverse_iterator
;
72 typedef typename_type_k
base_type::size_type size_type
;
73 typedef typename_type_k
base_type::bool_type bool_type
;
74 typedef typename_type_k
base_type::difference_type difference_type
;
75 typedef typename_type_k
base_type::int_type int_type
;
76 typedef typename_type_k
base_type::index_type index_type
;
80 #if defined(EXTL_COMPILER_IS_DMC) || \
81 defined(EXTL_COMPILER_IS_WATCOM)
82 friend class_type
operator+(class_type
const& lhs
, class_type
const& rhs
)
83 { basic_varray
<T
, B
> ret(lhs
); ret
+= rhs
; return ret
; }
84 friend class_type
operator+(class_type
const& lhs
, const_reference rhs
)
85 { basic_varray
<T
, B
> ret(lhs
); ret
+= rhs
; return ret
; }
86 friend class_type
operator+(const_reference lhs
, class_type
const& rhs
)
87 { basic_varray
<T
, B
> ret(rhs
); ret
+= lhs
; return ret
; }
89 friend class_type
operator-(class_type
const& lhs
, class_type
const& rhs
)
90 { basic_varray
<T
, B
> ret(lhs
); ret
-= rhs
; return ret
; }
91 friend class_type
operator-(class_type
const& lhs
, const_reference rhs
)
92 { basic_varray
<T
, B
> ret(lhs
); ret
-= rhs
; return ret
; }
94 friend class_type
operator*(class_type
const& lhs
, const_reference rhs
)
95 { basic_varray
<T
, B
> ret(lhs
); ret
*= rhs
; return ret
; }
96 friend class_type
operator*(const_reference lhs
, class_type
const& rhs
)
97 { basic_varray
<T
, B
> ret(rhs
); ret
*= lhs
; return ret
; }
99 friend class_type
operator/(class_type
const& lhs
, const_reference rhs
)
100 { basic_varray
<T
, B
> ret(lhs
); ret
/= rhs
; return ret
; }
102 friend class_type
operator^(class_type
const& lhs
, class_type
const& rhs
)
103 { basic_varray
<T
, B
> ret(lhs
); ret
^= rhs
; return ret
; }
104 friend class_type
operator^(class_type
const& lhs
, const_reference rhs
)
105 { basic_varray
<T
, B
> ret(lhs
); ret
^= rhs
; return ret
; }
106 friend class_type
operator^(const_reference lhs
, class_type
const& rhs
)
107 { basic_varray
<T
, B
> ret(rhs
); ret
^= lhs
; return ret
; }
109 friend class_type
operator&(class_type
const& lhs
, class_type
const& rhs
)
110 { basic_varray
<T
, B
> ret(lhs
); ret
&= rhs
; return ret
; }
111 friend class_type
operator&(class_type
const& lhs
, const_reference rhs
)
112 { basic_varray
<T
, B
> ret(lhs
); ret
&= rhs
; return ret
; }
113 friend class_type
operator&(const_reference lhs
, class_type
const& rhs
)
114 { basic_varray
<T
, B
> ret(rhs
); ret
&= lhs
; return ret
; }
116 friend class_type
operator|(class_type
const& lhs
, class_type
const& rhs
)
117 { basic_varray
<T
, B
> ret(lhs
); ret
|= rhs
; return ret
; }
118 friend class_type
operator|(class_type
const& lhs
, const_reference rhs
)
119 { basic_varray
<T
, B
> ret(lhs
); ret
|= rhs
; return ret
; }
120 friend class_type
operator|(const_reference lhs
, class_type
const& rhs
)
121 { basic_varray
<T
, B
> ret(rhs
); ret
|= lhs
; return ret
; }
123 friend class_type
operator>>(class_type
const& lhs
, class_type
const& rhs
)
124 { basic_varray
<T
, B
> ret(lhs
); ret
>>= rhs
; return ret
; }
125 friend class_type
operator>>(class_type
const& lhs
, const_reference rhs
)
126 { basic_varray
<T
, B
> ret(lhs
); ret
>>= rhs
; return ret
; }
128 friend class_type
operator<<(class_type
const& lhs
, class_type
const& rhs
)
129 { basic_varray
<T
, B
> ret(lhs
); ret
<<= rhs
; return ret
; }
130 friend class_type
operator<<(class_type
const& lhs
, const_reference rhs
)
131 { basic_varray
<T
, B
> ret(lhs
); ret
<<= rhs
; return ret
; }
133 friend class_type
operator%(class_type
const& lhs
, class_type
const& rhs
)
134 { basic_varray
<T
, B
> ret(lhs
); ret
%= rhs
; return ret
; }
135 friend class_type
operator%(class_type
const& lhs
, const_reference rhs
)
136 { basic_varray
<T
, B
> ret(lhs
); ret
%= rhs
; return ret
; }
139 /// \name Constructors
146 basic_varray(class_type
const& rhs
)
150 basic_varray(const_pointer ar
, size_type n
)
154 basic_varray(const_reference value
, size_type n
)
155 : base_type(value
, n
)
158 explicit_k
basic_varray(size_type n
)
167 class_type
& operator=(class_type
const& ar
) { return base_type::operator=(ar
); }
168 class_type
& operator=(const_reference value
) { return base_type::operator=(value
); }
172 /* ///////////////////////////////////////////////////////////////////////
177 /* //////////////////////////////////////////////////////////////////// */
178 #endif /* EXTL_MATH_BASIC_VARRAY_H */
179 /* //////////////////////////////////////////////////////////////////// */