template <class FormatString, class T1, ..., class Tn>
int snprintf(char *dst, size_t size, T1 a1, ..., Tn an);


Wrapper of the snprintf function of the C library. It takes the format string as a compile-time string, which is an boost::metaparse::string. It type-checks the arguments based on the format string. When type-checking fails, this function emits a compilation error. When type-checking succeeds, this function calls the snprintf function of the C library. This thin wrapper is likely to be inlined in which case it has no runtime overhead compared to using snprintf without type-checking.

#include <mpllibs/safe_printf/snprintf.hpp>

Expression semantics

For any s boost::metaparse::string, buf char pointer and a1 ... an runtime objects:

mpllibs::safe_printf::snprintf<s>(buf, a1, ..., an)

When the number and types of a1 ... an are correct according to s, the format string, it is equivalent to

std::snprintf(buf, boost::mpl::c_str<s>::type::value, a1, ..., an)

otherwise it is a compilation error.


char s[32];
>(s, 32, 11, 13);