Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
stan
math
prim
scal
err
out_of_range.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_PRIM_SCAL_ERR_OUT_OF_RANGE_HPP
2
#define STAN_MATH_PRIM_SCAL_ERR_OUT_OF_RANGE_HPP
3
4
#include <
stan/math/prim/scal/meta/error_index.hpp
>
5
#include <typeinfo>
6
#include <sstream>
7
#include <stdexcept>
8
9
namespace
stan
{
10
namespace
math
{
11
12
/**
13
* Throw an out_of_range exception with a consistently formatted message.
14
*
15
* This is an abstraction for all Stan functions to use when throwing
16
* out of range. This will allow us to change the behavior for all
17
* functions at once.
18
*
19
* The message is:
20
* "<function>: index <index> out of range; expecting index to be between "
21
* "1 and <max><msg1><msg2>"
22
*
23
* @param function Name of the function
24
* @param max Max
25
* @param index Index
26
* @param msg1 Message to print. Default is "".
27
* @param msg2 Message to print. Default is "".
28
* @throw std::out_of_range with message.
29
*/
30
inline
void
out_of_range
(
const
char
*
function
,
int
max
,
int
index
,
31
const
char
* msg1 =
""
,
const
char
* msg2 =
""
) {
32
std::ostringstream
message
;
33
34
message <<
function
<<
": accessing element out of range. "
35
<<
"index "
<< index <<
" out of range; "
36
<<
"expecting index to be between "
<<
stan::error_index::value
37
<<
" and "
<<
stan::error_index::value
- 1 + max << msg1 << msg2;
38
39
throw
std::out_of_range
(message.str());
40
}
41
42
}
// namespace math
43
}
// namespace stan
44
#endif
allTimeWatchdog.index
index
Definition:
allTimeWatchdog.py:18
datagram_client.message
string message
Definition:
datagram_client.py:91
stan
Definition:
StanTypedefs.h:9
math
stan::math::out_of_range
void out_of_range(const char *function, int max, int index, const char *msg1="", const char *msg2="")
Definition:
out_of_range.hpp:30
stan::math::max
int max(const std::vector< int > &x)
Definition:
max.hpp:22
error_index.hpp
stan::error_index::value
Definition:
error_index.hpp:8
Generated on Sat Jan 16 2021 14:15:38 for NOvA by
1.8.11