VectorBuilder.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HPP
2 #define STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HPP
3 
6 
7 namespace stan {
8 
9 /**
10  *
11  * VectorBuilder allocates type T1 values to be used as
12  * intermediate values. There are 2 template parameters:
13  * - used: boolean variable indicating whether this instance
14  * is used. If this is false, there is no storage allocated
15  * and operator[] throws.
16  * - is_vec: boolean variable indicating whether this instance
17  * should allocate a vector, if it is used. If this is false,
18  * the instance will only allocate a single double value.
19  * If this is true, it will allocate the number requested.
20  * Note that this is calculated based on template parameters
21  * T2 through T7.
22  *
23  * These values are mutable.
24  */
25 template <bool used, typename T1, typename T2, typename T3 = double,
26  typename T4 = double, typename T5 = double, typename T6 = double,
27  typename T7 = double>
29  private:
30  typedef VectorBuilderHelper<T1, used,
33 
34  public:
35  typedef typename helper::type type;
37 
38  explicit VectorBuilder(size_t n) : a(n) {}
39 
40  T1& operator[](size_t i) { return a[i]; }
41 
42  inline type data() { return a.data(); }
43 };
44 
45 } // namespace stan
46 #endif
T1 & operator[](size_t i)
VectorBuilderHelper< T1, used, contains_vector< T2, T3, T4, T5, T6, T7 >::value > helper