struct writer
{
template <typename T> T &operator<<(T x)
{
static_assert(is_integral<T>::value, "only interger!");
int sta[50];
int tp = 0;
do
{
sta[tp++] = x % 10;x /= 10;
} while (x);
while (tp) putchar(sta[--tp] + '0');
}
} write;
调用
int x = 48;
write << x;