mCRL2
Loading...
Searching...
No Matches
fixed_vector.h
Go to the documentation of this file.
1// Author(s): David N. Jansen, Radboud Universiteit, Nijmegen, The Netherlands
2//
3// Copyright: see the accompanying file COPYING or copy at
4// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
23
24#ifndef FIXED_VECTOR_H
25#define FIXED_VECTOR_H
26
27#include <vector>
28#include <cassert>
29
30namespace mcrl2
31{
32namespace lts
33{
34namespace detail
35{
36
37template <class T>
38class fixed_vector : private std::vector<T>
39{
40public:
41 // only reveal as much of the interface of std::vector<T> as is needed:
42 using typename std::vector<T>::iterator;
43 using typename std::vector<T>::const_iterator;
44 using typename std::vector<T>::size_type;
45 using std::vector<T>::begin;
46 using std::vector<T>::cbegin;
47 using std::vector<T>::cend;
48 using std::vector<T>::end;
49 using std::vector<T>::front;
50 using std::vector<T>::back;
51 using std::vector<T>::size;
52 using std::vector<T>::clear;
53 using std::vector<T>::empty;
54 using std::vector<T>::data;
55
56 explicit fixed_vector(size_type n) :std::vector<T>(n) { }
57 explicit fixed_vector(size_type n, T init) :std::vector<T>(n, init) { }
58
59#ifdef NDEBUG
60 using std::vector<T>::operator[];
61#else
62 // operator[] calls std::vector<T>::at because the latter checks bounds.
63 T& operator[](size_type n) { return std::vector<T>::at(n); }
64 const T& operator[](size_type n) const { return std::vector<T>::at(n); }
65#endif
66};
67
68} // end namespace detail
69} // end namespace lts
70} // end namespace mcrl2
71
72#endif // #ifndef FIXED_VECTOR_H
A vector class in which aterms can be stored.
Definition vector.h:34
fixed_vector(size_type n, T init)
const T & operator[](size_type n) const
MCRL2_EXPORT bool init(rewriter_interface *i, RewriterCompilingJitty *this_rewriter)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
STL namespace.