1 #ifndef TEUCHOS_VECTOR_HPP
2 #define TEUCHOS_VECTOR_HPP
5 #include <Teuchos_Assert.hpp>
13 inline int size(std::vector<T>
const& v) {
18 inline typename std::vector<T>::reference at(std::vector<T>& v,
int i) {
19 TEUCHOS_DEBUG_ASSERT(0 <= i);
20 TEUCHOS_DEBUG_ASSERT(i <
int(v.size()));
21 return v[std::size_t(i)];
25 inline typename std::vector<T>::const_reference at(std::vector<T>
const& v,
int i) {
26 TEUCHOS_DEBUG_ASSERT(0 <= i);
27 TEUCHOS_DEBUG_ASSERT(i <
int(v.size()));
28 return v[std::size_t(i)];
32 inline void resize(std::vector<T>& v,
int n) {
33 TEUCHOS_DEBUG_ASSERT(0 <= n);
34 v.resize(std::size_t(n));
38 inline void reserve(std::vector<T>& v,
int n) {
39 TEUCHOS_DEBUG_ASSERT(0 <= n);
40 v.reserve(std::size_t(n));
44 inline std::vector<T> make_vector(
int n, T
const& init_val = T()) {
45 return std::vector<T>(std::size_t(n), init_val);
49 void add_back(std::vector<T>& vector, T& value) {
51 vector.push_back(T());
52 swap(vector.back(), value);