Stan Math Library  2.14.0
reverse mode automatic differentiation
check_std_vector_index.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_STD_VECTOR_INDEX_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_STD_VECTOR_INDEX_HPP
3 
5 
6 #include <sstream>
7 #include <string>
8 #include <vector>
9 
10 namespace stan {
11  namespace math {
12 
28  template <typename T>
29  inline void check_std_vector_index(const char* function,
30  const char* name,
31  const std::vector<T>& y,
32  int i) {
33  if (i >= static_cast<int>(stan::error_index::value)
34  && i < static_cast<int>(y.size() + stan::error_index::value))
35  return;
36 
37  std::stringstream msg;
38  msg << " for " << name;
39  std::string msg_str(msg.str());
40  out_of_range(function, y.size(), i, msg_str.c_str());
41  }
42 
43  }
44 }
45 #endif
void check_std_vector_index(const char *function, const char *name, const std::vector< T > &y, int i)
Check if the specified index is valid in std vector.
void out_of_range(const char *function, int max, int index, const char *msg1="", const char *msg2="")
Throw an out_of_range exception with a consistently formatted message.

     [ Stan Home Page ] © 2011–2016, Stan Development Team.