Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
check_std_vector_index.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_STD_VECTOR_INDEX_HPP
2 #define STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_STD_VECTOR_INDEX_HPP
3 
4 #include <sstream>
5 #include <vector>
7 
8 namespace stan {
9  namespace math {
10 
24  template <typename T_y, typename T_result>
25  inline bool check_std_vector_index(const char* function,
26  size_t i,
27  const std::vector<T_y>& y,
28  const char* name,
29  T_result* result) {
30  if ((i > 0) && (i <= static_cast<size_t>(y.size())))
31  return true;
32 
33  std::ostringstream msg;
34  msg << name << " (%1%) must be greater than 0 and less than "
35  << y.size();
36  std::string tmp(msg.str());
37  return dom_err(function,i,name,
38  tmp.c_str(),"",
39  result);
40  }
41 
42  }
43 }
44 #endif
bool dom_err(const char *function, const T &y, const char *name, const char *error_msg, const T_msg error_msg2, T_result *result)
Definition: dom_err.hpp:36
bool check_std_vector_index(const char *function, size_t i, const std::vector< T_y > &y, const char *name, T_result *result)
Return true if the specified index is valid in std vector.

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