Stan Math Library  2.20.0
reverse mode automatic differentiation
domain_error.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_DOMAIN_ERROR_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_DOMAIN_ERROR_HPP
3 
5 #include <typeinfo>
6 #include <sstream>
7 #include <stdexcept>
8 
9 namespace stan {
10 namespace math {
11 
26 template <typename T>
27 inline void domain_error(const char* function, const char* name, const T& y,
28  const char* msg1, const char* msg2) {
29  std::ostringstream message;
30  // hack to remove -Waddress, -Wnonnull-compare warnings from GCC 6
31  const T* y_ptr = &y;
32  message << function << ": " << name << " " << msg1 << (*y_ptr) << msg2;
33  throw std::domain_error(message.str());
34 }
35 
49 template <typename T>
50 inline void domain_error(const char* function, const char* name, const T& y,
51  const char* msg1) {
52  domain_error(function, name, y, msg1, "");
53 }
54 
55 } // namespace math
56 } // namespace stan
57 #endif
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
void domain_error(const char *function, const char *name, const T &y, const char *msg1)
Throw a domain error with a consistently formatted message.

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