1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_EQUAL_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_EQUAL_HPP
15 template <
typename T_y,
19 static bool check(
const char*
function,
24 VectorView<const T_eq> eq_vec(eq);
25 for (
size_t n = 0; n <
length(eq); n++) {
26 if (!(y == eq_vec[n])) {
27 std::stringstream msg;
28 msg <<
", but must be equal to ";
30 std::string msg_str(msg.str());
33 "is ", msg_str.c_str());
41 template <
typename T_y,
43 struct equal<T_y, T_eq, true> {
44 static bool check(
const char*
function,
50 VectorView<const T_eq> eq_vec(eq);
51 for (
size_t n = 0; n <
length(y); n++) {
52 if (!(
get(y, n) == eq_vec[n])) {
53 std::stringstream msg;
54 msg <<
", but must be equal to ";
56 std::string msg_str(msg.str());
58 "is ", msg_str.c_str());
89 template <
typename T_y,
typename T_eq>
94 return equal<T_y, T_eq, is_vector_like<T_y>::value>
95 ::check(
function, name, y, eq);
size_t length(const std::vector< T > &x)
void domain_error_vec(const char *function, const char *name, const T &y, const size_t i, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
bool check_equal(const char *function, const char *name, const T_y &y, const T_eq &eq)
Return true if y is equal to eq.
T get(const std::vector< T > &x, size_t n)
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.