static inline T op1_impl(Op op, T x) { switch (op) { case OP_NEG: return neg_impl(x); case OP_INV: return inv_impl(x); case OP_SQ: return sq_impl(x); case OP_CU: return cu_impl(x); case OP_SQRT: return sqrt_impl(x); case OP_SIN: return sin_impl(x); case OP_COS: return cos_impl(x); case OP_TAN: return tan_impl(x); case OP_ASIN: return asin_impl(x); case OP_ACOS: return acos_impl(x); case OP_ATAN: return atan_impl(x); case OP_SINH: return sinh_impl(x); case OP_COSH: return cosh_impl(x); case OP_TANH: return tanh_impl(x); case OP_ASINH: return asinh_impl(x); case OP_ACOSH: return acosh_impl(x); case OP_ATANH: return atanh_impl(x); case OP_EXP: return exp_impl(x); case OP_LOG: return log_impl(x); case OP_ERF: return erf_impl(x); case OP_ERFC: return erfc_impl(x); case OP_ABS: return abs_impl(x); case OP_FLOOR: return floor_impl(x); case OP_CEIL: return ceil_impl(x); case OP_ROUND: return round_impl(x); case OP_TRUNC: return trunc_impl(x); default: throw std::invalid_argument("Wrong number of arguments for operator"); } }
void log_message(int prefix, int suffix, const char *fun, const char *fmt, ...) { va_list ap; va_start(ap, fmt); log_impl(prefix, suffix, fun, fmt, ap); va_end(ap); }
void debug(const char *fun, const char *fmt, ...) { va_list ap; if (!debug_flag) return; va_start(ap, fmt); log_impl(1, 1, fun, fmt, ap); va_end(ap); }
bool AssertDetailImpl::log_impl(const AssertDetailImpl* adi) { if (!adi) return false; log_impl(adi->m_next); auto const title = folly::format("{:-^80}\n", adi->m_name).str(); auto const msg = adi->run(); fprintf(stderr, "\n%s%s\n", title.c_str(), msg.c_str()); if (s_logger) s_logger(title.c_str(), msg); return true; }
bool AssertDetailImpl::log() { return log_impl(s_head); }