Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
dom_err.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__ERROR_HANDLING__DOM_ERR_HPP__
2 #define __STAN__MATH__ERROR_HANDLING__DOM_ERR_HPP__
3 
4 #include <sstream>
6 
7 namespace stan {
8  namespace math {
9 
10  namespace {
11  // local output stream for pairs
12  template <typename T1, typename T2>
13  std::ostream& operator<<(std::ostream& o,
14  std::pair<T1,T2> xs) {
15  o << '(' << xs.first << ", " << xs.second << ')';
16  return o;
17  }
18  }
19 
20 
21  template <typename T_y,
22  typename T_result,
23  typename T_msg2,
24  class Policy>
25  inline bool dom_err(const char* function,
26  const T_y& y,
27  const char* name,
28  const char* error_msg,
29  T_msg2 error_msg2,
30  T_result* result,
31  const Policy&) {
33  std::ostringstream msg_o;
34  msg_o << name << error_msg << error_msg2;
35  T_result tmp = raise_domain_error<T_result,T_y>(function,
36  msg_o.str().c_str(),
37  y,
38  Policy());
39  if (result != 0)
40  *result = tmp;
41  return false;
42  }
43 
44  }
45 }
46 #endif

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