32 #ifndef VSMC_INTERNAL_ASSERT_HPP 33 #define VSMC_INTERNAL_ASSERT_HPP 44 #pragma clang diagnostic push 45 #pragma clang diagnostic ignored "-Wweak-vtables" 48 #if VSMC_NO_RUNTIME_ASSERT 49 #define VSMC_RUNTIME_ASSERT(cond, msg) 50 #else // VSMC_NO_RUNTIME_ASSERT 51 #if VSMC_RUNTIME_ASSERT_AS_EXCEPTION 52 #define VSMC_RUNTIME_ASSERT(cond, msg) \ 55 throw ::vsmc::RuntimeAssert(msg); \ 58 #else // VSMC_RUNTIME_ASSERT_AS_EXCEPTION 59 #define VSMC_RUNTIME_ASSERT(cond, msg) \ 62 std::fprintf(stderr, "vSMC runtime assertion failed:%s\n", msg); \ 63 std::fflush(stderr); \ 67 #endif // VSMC_RUNTIME_ASSERT_AS_EXCEPTION 68 #endif // VSMC_NO_RUNTIME_ASSERT 70 #if VSMC_NO_RUNTIME_WARNING 71 #define VSMC_RUNTIME_WARNING(cond, msg) 72 #else // VSMC_NO_RUNTIME_WARNING 73 #if VSMC_RUNTIME_WARNING_AS_EXCEPTION 74 #define VSMC_RUNTIME_WARNING(cond, msg) \ 77 throw ::vsmc::RuntimeWarning(msg); \ 80 #else // VSMC_RUNTIME_WARNING_AS_EXCEPTION 81 #define VSMC_RUNTIME_WARNING(cond, msg) \ 84 std::fprintf(stderr, "vSMC runtime warning:%s\n", msg); \ 85 std::fflush(stderr); \ 88 #endif // VSMC_RUNTIME_WARNING_AS_EXCEPTION 89 #endif // VSMC_NO_RUNTIME_WARNING 115 #if VSMC_NO_RUNTIME_ASSERT 116 template <
typename IntType,
typename SizeType>
120 #else // VSMC_NO_RUNTIME_ASSERT 121 template <
typename IntType,
typename SizeType>
124 static constexpr std::uintmax_t nmax =
125 static_cast<std::uintmax_t
>(std::numeric_limits<IntType>::max());
129 msg +=
"** INPUT SIZE TOO BIG";
133 #endif // VSMC_NO_RUNTIME_ASSERT 140 #pragma clang diagnostic pop 143 #endif // VSMC_INTERNAL_ASSERT_HPP
RuntimeAssert(const std::string &msg)
void size_check(SizeType n, const char *f)
#define VSMC_RUNTIME_ASSERT(cond, msg)
RuntimeWarning(const char *msg)
RuntimeAssert(const char *msg)
typename SizeTypeTrait< T >::type SizeType
RuntimeWarning(const std::string &msg)