P4C
The P4 Compiler
Loading...
Searching...
No Matches
safe_vector.h
1/*
2 * SPDX-FileCopyrightText: 2013 Barefoot Networks, Inc.
3 * Copyright 2013-present Barefoot Networks, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef LIB_SAFE_VECTOR_H_
9#define LIB_SAFE_VECTOR_H_
10
11#include <vector>
12
13namespace P4 {
14
17template <class T, class Alloc = std::allocator<T>>
18class safe_vector : public std::vector<T, Alloc> {
19 public:
20 using std::vector<T, Alloc>::vector;
21 typedef typename std::vector<T, Alloc>::reference reference;
22 typedef typename std::vector<T, Alloc>::const_reference const_reference;
23 typedef typename std::vector<T, Alloc>::size_type size_type;
24 typedef typename std::vector<T>::const_iterator const_iterator;
25 reference operator[](size_type n) { return this->at(n); }
26 const_reference operator[](size_type n) const { return this->at(n); }
27};
28
29} // namespace P4
30
31#endif /* LIB_SAFE_VECTOR_H_ */
Definition safe_vector.h:18
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13