1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_NONNEGATIVE_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_NONNEGATIVE_HPP
9 #include <boost/type_traits/is_unsigned.hpp>
16 template <
typename T_y,
bool is_vec>
18 static bool check(
const char*
function,
23 if (!boost::is_unsigned<T_y>::value && !(y >= 0))
25 "is ",
", but must be >= 0!");
30 template <
typename T_y>
31 struct nonnegative<T_y, true> {
32 static bool check(
const char*
function,
38 for (
size_t n = 0; n <
length(y); n++) {
39 if (!boost::is_unsigned<
typename value_type<T_y>::type>::value
42 "is ",
", but must be >= 0!");
65 template <
typename T_y>
69 return nonnegative<T_y, is_vector_like<T_y>::value>
70 ::check(
function, name, y);
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.
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.
bool check_nonnegative(const char *function, const char *name, const T_y &y)
Return true if y is non-negative.
Primary template class for metaprogram to compute the type of values stored in a container.