1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef MED_Vector_HeaderFile
24 #define MED_Vector_HeaderFile
29 # define MED_TVECTOR_CHECK_RANGE
33 //! Main purpose to introduce the class was to customize operator []
34 template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
35 class TVector : public std::vector<_Tp, _Alloc>
38 typedef size_t size_type;
40 typedef std::vector<_Tp, _Alloc> superclass;
41 typedef typename superclass::allocator_type allocator_type;
43 typedef _Tp value_type;
44 typedef value_type& reference;
45 typedef const value_type& const_reference;
49 check_range(size_type __n) const
51 if (__n >= this->size())
52 throw std::out_of_range("TVector [] access out of range");
56 get_value(size_type __n) const
58 return superclass::operator[](__n);
62 get_value(size_type __n)
64 return superclass::operator[](__n);
69 TVector(const allocator_type& __a = allocator_type()):
73 TVector(size_type __n, const value_type& __val,
74 const allocator_type& __a = allocator_type()):
75 superclass(__n, __val, __a)
79 TVector(size_type __n):
83 TVector(const TVector& __x):
87 template<typename _InputIterator>
88 TVector(_InputIterator __first, _InputIterator __last,
89 const allocator_type& __a = allocator_type()):
90 superclass(__first, __last, __a)
93 template<typename _Yp, typename _Al>
94 TVector(TVector<_Yp, _Al> __y):
95 superclass(__y.begin(), __y.end())
99 operator=(const TVector& __x)
101 superclass::operator=(__x);
105 template<typename _Yp, typename _Al>
107 operator=(TVector<_Yp, _Al> __y)
109 this->assign(__y.begin(), __y.end());
114 operator[](size_type __n)
116 #if defined(MED_TVECTOR_CHECK_RANGE)
119 return get_value(__n);
123 operator[](size_type __n) const
125 #if defined(MED_TVECTOR_CHECK_RANGE)
128 return get_value(__n);
135 return get_value(__n);
139 at(size_type __n) const
142 return get_value(__n);
147 #undef MED_TVECTOR_CHECK_RANGE
149 #endif // MED_Vector_HeaderFile