eATM

fmtlib 处理空字符串抛出异常,string pointer is null

template 
FMT_CONSTEXPR_CHAR_TRAITS auto write(OutputIt out, const Char* value)
-> OutputIt
{
	//添加-处理字符串空指针抛出异常
	if (!value) value = "null";

	//if (!value) {
		//FMT_THROW(format_error("string pointer is null"));
	//} else {
		auto length = std::char_traits::length(value);
		out = write(out, basic_string_view(value, length));
	//}
	return out;
}

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注