implement an utils::print() function similar to fmt::print()
this doesn't have the constexpr requirement for the format string. also it will help porting to std::format in C++20, which doesn't have a similar functionality either.
This commit is contained in:
@ -262,6 +262,22 @@ void utils::fmtargs_logmesg(LAMMPS *lmp, fmt::string_view format, fmt::format_ar
|
||||
}
|
||||
}
|
||||
|
||||
/* specialization for the case of just a single string argument */
|
||||
|
||||
void utils::print(FILE *fp, const std::string &mesg)
|
||||
{
|
||||
fputs(mesg.c_str(), fp);
|
||||
}
|
||||
|
||||
void utils::fmtargs_print(FILE *fp, fmt::string_view format, fmt::format_args args)
|
||||
{
|
||||
try {
|
||||
print(fp, fmt::vformat(format, args));
|
||||
} catch (fmt::format_error &) {
|
||||
; // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
std::string utils::errorurl(int errorcode)
|
||||
{
|
||||
return fmt::format("\nFor more information see https://docs.lammps.org/err{:04d}", errorcode);
|
||||
|
||||
Reference in New Issue
Block a user