13 template <std::size_t N,
typename... Args>
14 int Sprintf(
char (&
buf)[N],
const char* fmt, Args&&... args) {
15 if constexpr (
sizeof...(Args) == 0) {
17 return std::snprintf(
buf, N,
"%s", fmt);
19 return std::snprintf(
buf, N, fmt, std::forward<Args>(args)...);
26 template <std::size_t N,
typename... Args>
28 int sz =
Sprintf(
buf, fmt, std::forward<Args>(args)...);
30 if (sz < 0 || std::size_t(sz) >= N) {
31 throw std::runtime_error(
"SprintfAsrt buffer too small or snprintf error");
34 assert(sz >= 0 && std::size_t(sz) < N);
In mechanism libraries, cannot use auto const token = nrn_ensure_model_data_are_sorted(); because the...
void SprintfAsrt(char(&buf)[N], const char *fmt, Args &&... args)
assert if the Sprintf format data does not fit into buf
int Sprintf(char(&buf)[N], const char *fmt, Args &&... args)
Redirect sprintf to snprintf if the buffer size can be deduced.