InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
K2Vector.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Mat Marcus and Jesse Jones
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __K2Vector__
25 #define __K2Vector__
26 
27 #include "K2VectorBase.h"
28 #include "K2PtrVectorBase.h"
29 
30 //template <typename T, class Allocator>
31 //struct GENERATE_VECTOR {
32 // typedef typename K2Meta::IF_IS_PTR<T, K2Internals::K2PtrVectorBase<T>, K2Internals::K2VectorBase<T, Allocator> >::RET RET;
33 //};
34 
68 template <class T, class Allocator = K2Allocator<T> >
69 class K2Vector : public K2Internals::K2VectorBase<T, Allocator> {
70 
72  typedef void (K2Vector::*Method)();
73 
74  public:
79  explicit K2Vector(/*const Allocator& a = Allocator()*/) : Inherited() {}
80 
86  K2Vector(typename Allocator::size_type count, const T& value
87  /*, const Allocator& a = Allocator()*/)
88  : Inherited(static_cast<typename Inherited::size_type>(count), value) {}
89 
95  K2Vector(const K2Vector& rhs) = default;
96  K2Vector(K2Vector&& rhs) noexcept = default;
97  K2Vector &operator=(const K2Vector& rhs) = default;
98  K2Vector &operator=(K2Vector&& rhs) noexcept = default;
99 
100  // MSVC 6.5 gets internal compiler errors if we try to use a default allocator parameter instead of
101  //using two constructors here
102 
109  template <class InputIterator>
110  K2Vector(InputIterator first, InputIterator last, const Allocator& a)
111  : Inherited(first, last, a) {}
112 
113 
119  template <class InputIterator>
120  K2Vector(InputIterator first, InputIterator last)
121  : Inherited(first, last, Allocator()) {}
122 
123  void swap(K2Vector &other) noexcept
124  {
125  this->Inherited::swap(static_cast<Inherited &>(other));
126  }
127 
128 /* Documentation
129  typedef T value_type;
130  typedef value_type* pointer;
131  typedef const value_type* const_pointer;
132  typedef value_type* iterator;
133  typedef const value_type* const_iterator;
134  typedef value_type& reference;
135  typedef const value_type& const_reference;
136  typedef size_t size_type;
137  typedef ptrdiff_t difference_type;
138  typedef Allocator allocator_type;
139 
140  typedef K2Reverse_iterator<iterator, value_type, difference_type, pointer, reference> reverse_iterator;
141  typedef K2Reverse_iterator<const_iterator, value_type, difference_type, const_pointer, const_reference> const_reverse_iterator;
142 
143 
144  iterator begin();
145  const_iterator begin() const;
146  iterator end();
147  const_iterator end() const;
148  reverse_iterator rbegin();
149  const_reverse_iterator rbegin() const;
150  reverse_iterator rend();
151  const_reverse_iterator rend() const;
152 
153  size_type size() const;
154  size_type max_size() const;
155  size_type capacity() const;
156  bool16 empty() const;
157 
158  allocator_type get_allocator() const;
159 
160 
161  void assign(size_type count, const T& v);
162 
163  template <class InputIter>
164  void assign(InputIter first, InputIter last);
165 
166  reference operator[](size_type i);
167  const_reference operator[](size_type i) const;
168  reference at(size_type i);
169  const_reference at(size_type i) const;
170  reference front();
171  const_reference front() const;
172  reference back();
173  const_reference back() const;
174 
175  void push_back(const T& x);
176  void pop_back();
177  iterator insert(iterator position, const T& x);
178  void insert(iterator position, size_type n, const T& x);
179 
180  template <class InputIter>
181  void insert(iterator pos, InputIter first, InputIter last);
182 
183 
184  iterator erase(iterator position);
185  iterator erase(iterator first, iterator last);
186  void swap(K2Vector& rhs);
187  void clear();
188  void resize(size_type sz, const T& value);
189  void reserve(size_type sz, const T& value);
190 
191 
192 
193 
194 
195 */
196 
197 
198  static Method ForceInstantiation(int n);
199  // Force instantiation of all inherited outlined functions so that
200  // clients can explicitly instantiate K2Vector instead of K2VectorBase.
201 };
202 
203 
204 template <class U >
207  typedef void (K2Vector::*Method)();
208  typedef K2Allocator<U*> Allocator;
209  public:
210  explicit K2Vector(/*const Allocator& a = Allocator()*/) : Inherited() {}
211 
212  K2Vector(typename Allocator::size_type count, U*const& value
213  /*, const Allocator& a = Allocator()*/)
214  : Inherited(count, value) {}
215 
216 
217  K2Vector(const K2Vector& rhs) = default;
218  K2Vector(K2Vector&& rhs) noexcept = default;
219  K2Vector &operator=(const K2Vector& rhs) = default;
220  K2Vector &operator=(K2Vector&& rhs) noexcept = default;
221 
222  void swap(K2Vector &other) noexcept
223  {
224  this->Inherited::swap(static_cast<Inherited &>(other));
225  }
226  // MSVC 6.5 gets internal compiler errors if we try to use a default allocator parameter instead of
227  //using two constructors here
228 
229  template <class InputIterator>
230  K2Vector(InputIterator first, InputIterator last, const Allocator& a)
231  : Inherited(first, last, a) {}
232 
233 
234  template <class InputIterator>
235  K2Vector(InputIterator first, InputIterator last)
236  : Inherited(first, last, Allocator()) {}
237 };
238 
239 template <class T/*, class Allocator*/>
240 inline void swap(K2Vector<T/*, Allocator*/>& x, K2Vector<T/*, Allocator*/>& y) noexcept
241 {
242  x.swap(y);
243 }
244 
245 #ifdef _INCLUDE_TPP_IN_H_
246  #include "K2Vector.tpp"
247 #endif //INCLUDE_TPP_IN_H_
248 
249 // specialize adobe::type_info<> to avoid typeid problems across DLL boundaries
250 ADOBE_NAME_TYPE_1("k2vector:indesign:adobe",K2Vector<T0,K2Allocator<T0> >)
251 ADOBE_NAME_TYPE_2("k2vector:indesign:adobe",K2Vector<T0, T1>)
252 
253 
254 #endif // __K2Vector__
255