32 #ifndef MCKL_INTERNAL_ASSERT_HPP 33 #define MCKL_INTERNAL_ASSERT_HPP 57 #if MCKL_NO_RUNTIME_ASSERT 61 inline void runtime_assert(
bool,
const std::string &,
bool =
false) {}
63 #else // MCKL_NO_RUNTIME_ASSERT 67 #if MCKL_RUNTIME_ASSERT_AS_EXCEPTION 69 throw ::mckl::RuntimeAssert(msg);
70 #else // MCKL_RUNTIME_ASSERT_AS_EXCEPTION 72 std::cerr <<
"MCKL runtime assertion failed: " << msg << std::endl;
75 #endif // MCKL_RUNTIME_ASSERT_AS_EXCEPTION 79 bool cond,
const std::string &msg,
bool soft =
false)
84 #endif // MCKL_NO_RUNTIME_ASSERT 86 template <
typename Except>
94 template <
typename Except>
97 runtime_assert<Except>(cond, msg.c_str());
102 #if MCKL_NO_RUNTIME_ASSERT 104 template <
typename IntType,
typename SizeType>
109 #else // MCKL_NO_RUNTIME_ASSERT 111 template <
typename IntType,
typename SizeType>
116 template <
typename IntType,
typename SizeType>
119 constexpr std::uintmax_t nmax =
120 static_cast<std::uintmax_t
>(std::numeric_limits<IntType>::max());
125 msg +=
"** input size too large";
127 runtime_assert((static_cast<std::uintmax_t>(n) <= nmax), msg.c_str());
130 template <
typename IntType,
typename SizeType>
133 constexpr std::uintmax_t nmax =
134 static_cast<std::uintmax_t
>(std::numeric_limits<IntType>::max());
135 constexpr std::uintmax_t smax =
136 static_cast<std::uintmax_t
>(std::numeric_limits<SizeType>::max());
138 size_check<IntType>(n, f, std::integral_constant<bool, (nmax < smax)>());
141 #endif // MCKL_NO_RUNTIME_ASSERT 143 template <
typename T>
146 return ptr ==
nullptr;
149 template <
typename T>
155 template <
typename T>
159 std::integral_constant<
bool,
160 (std::is_pointer<T>::value ||
161 std::is_same<std::nullptr_t, std::remove_cv_t<T>>::value)>());
172 #endif // MCKL_INTERNAL_ASSERT_HPP RuntimeAssert(const std::string &msg)
RuntimeAssert(const char *msg)
#define MCKL_PUSH_CLANG_WARNING(warning)
void runtime_assert(bool cond, const std::string &msg)
bool is_nullptr(std::nullptr_t)
#define MCKL_POP_CLANG_WARNING
void size_check(SizeType n, const char *f)
typename SizeTypeTrait< T >::type SizeType