validate_non_negative_index.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_VALIDATE_NON_NEGATIVE_INDEX_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_VALIDATE_NON_NEGATIVE_INDEX_HPP
3 
4 #include <sstream>
5 #include <stdexcept>
6 #include <string>
7 
8 namespace stan {
9 namespace math {
10 
11 inline void validate_non_negative_index(const char* var_name, const char* expr,
12  int val) {
13  if (val < 0) {
14  std::stringstream msg;
15  msg << "Found negative dimension size in variable declaration"
16  << "; variable=" << var_name << "; dimension size expression=" << expr
17  << "; expression value=" << val;
18  std::string msg_str(msg.str());
19  throw std::invalid_argument(msg_str.c_str());
20  }
21 }
22 
23 } // namespace math
24 } // namespace stan
25 #endif
void validate_non_negative_index(const char *var_name, const char *expr, int val)
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
enum BeamMode string