cprover
expanding_vector.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_UTIL_EXPANDING_VECTOR_H
11 #define CPROVER_UTIL_EXPANDING_VECTOR_H
12 
13 #include <vector>
14 
15 template<typename T>
16 class expanding_vectort:public std::vector<T>
17 {
18 public:
20  {
21  check_index(n);
22  return subt::operator[](n);
23  }
24 
25  const T &operator[] (typename std::vector<T>::size_type n) const
26  {
27  // hack-ish const cast
28  const_cast<expanding_vectort*>(this)->check_index(n);
29  return subt::operator[](n);
30  }
31 
32 protected:
33  typedef std::vector<T> subt;
34 
35  // make the vector large enough to contain 'n'
37  {
38  if(n>=subt::size())
39  subt::resize(n+1);
40  }
41 };
42 
43 #endif // CPROVER_UTIL_EXPANDING_VECTOR_H
unsignedbv_typet size_type()
Definition: c_types.cpp:57
void check_index(typename std::vector< T >::size_type n)
T & operator[](typename std::vector< T >::size_type n)
std::vector< T > subt