#include <cstdio>
#include <string>
template< typename T >
T const &printf_helper( T const &x )
{ return x; }
char const *printf_helper( std::string const &x )
{ return x.c_str(); }
template< typename ... Req, typename ... Given >
int wrap_printf( int (*fn)( Req ...... ), Given ... args ) {
return fn( printf_helper( args ) ... );
}
int main() {
wrap_printf( std::printf, "Hello %s\n", std::string( "world!" ) );
wrap_printf( std::fprintf, stderr, std::string( "Error %d" ), 5 );
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHN0cmluZz4KCnRlbXBsYXRlPCB0eXBlbmFtZSBUID4KVCBjb25zdCAmcHJpbnRmX2hlbHBlciggVCBjb25zdCAmeCApCiAgICB7IHJldHVybiB4OyB9CgpjaGFyIGNvbnN0ICpwcmludGZfaGVscGVyKCBzdGQ6OnN0cmluZyBjb25zdCAmeCApCiAgICB7IHJldHVybiB4LmNfc3RyKCk7IH0KCnRlbXBsYXRlPCB0eXBlbmFtZSAuLi4gUmVxLCB0eXBlbmFtZSAuLi4gR2l2ZW4gPgppbnQgd3JhcF9wcmludGYoIGludCAoKmZuKSggUmVxIC4uLi4uLiApLCBHaXZlbiAuLi4gYXJncyApIHsKICAgIHJldHVybiBmbiggcHJpbnRmX2hlbHBlciggYXJncyApIC4uLiApOwp9CgppbnQgbWFpbigpIHsKICAgIHdyYXBfcHJpbnRmKCBzdGQ6OnByaW50ZiwgIkhlbGxvICVzXG4iLCBzdGQ6OnN0cmluZyggIndvcmxkISIgKSApOwogICAgd3JhcF9wcmludGYoIHN0ZDo6ZnByaW50Ziwgc3RkZXJyLCBzdGQ6OnN0cmluZyggIkVycm9yICVkIiApLCA1ICk7Cn0=