#include <iostream>
#include <vector>
using namespace std;
enum types
{
INT,
DOUBLE,
CHAR,
STRING
};
struct multitype
{
types type;
union
{
int i;
double d;
char c;
const char *s;
} val;
multitype(int i)
: type(INT)
{
val.i = i;
}
multitype(double d)
: type(DOUBLE)
{
val.d = d;
}
multitype(char c)
: type(CHAR)
{
val.c = c;
}
multitype(const char *s)
: type(STRING)
{
val.s = s;
}
};
struct helper
{
vector<multitype> arr;
template<typename T>
helper& operator ,(T x)
{
arr.push_back(multitype(x));
return *this;
}
};
void print(const helper& h)
{
for (int i = 0; i < h.arr.size(); i++)
{
const multitype& x = h.arr[i];
switch (x.type)
{
case INT:
cout << x.val.i << endl;
break;
case DOUBLE:
cout << x.val.d << endl;
break;
case CHAR:
cout << x.val.c << endl;
break;
case STRING:
cout << x.val.s << endl;
break;
}
}
}
#define PRINT(...) print((helper(), __VA_ARGS__))
int main()
{
PRINT(2, 4.2, 'a', "Hello");
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmVudW0gdHlwZXMKewogICAgSU5ULAogICAgRE9VQkxFLAogICAgQ0hBUiwKICAgIFNUUklORwp9OwoKc3RydWN0IG11bHRpdHlwZQp7CiAgICB0eXBlcyB0eXBlOwoKICAgIHVuaW9uCiAgICB7CiAgICAgICAgaW50ICAgICAgICAgaTsKICAgICAgICBkb3VibGUgICAgICBkOwogICAgICAgIGNoYXIgICAgICAgIGM7CiAgICAgICAgY29uc3QgY2hhciAqczsKICAgIH0gdmFsOwoKICAgIG11bHRpdHlwZShpbnQgaSkKICAgICAgICA6IHR5cGUoSU5UKQogICAgewogICAgICAgIHZhbC5pID0gaTsKICAgIH0KCiAgICBtdWx0aXR5cGUoZG91YmxlIGQpCiAgICAgICAgOiB0eXBlKERPVUJMRSkKICAgIHsKICAgICAgICB2YWwuZCA9IGQ7CiAgICB9CgogICAgbXVsdGl0eXBlKGNoYXIgYykKICAgICAgICA6IHR5cGUoQ0hBUikKICAgIHsKICAgICAgICB2YWwuYyA9IGM7CiAgICB9CgogICAgbXVsdGl0eXBlKGNvbnN0IGNoYXIgKnMpCiAgICAgICAgOiB0eXBlKFNUUklORykKICAgIHsKICAgICAgICB2YWwucyA9IHM7CiAgICB9Cn07CgpzdHJ1Y3QgaGVscGVyCnsKICAgIHZlY3RvcjxtdWx0aXR5cGU+IGFycjsKCiAgICB0ZW1wbGF0ZTx0eXBlbmFtZSBUPgogICAgaGVscGVyJiBvcGVyYXRvciAsKFQgeCkKICAgIHsKICAgICAgICBhcnIucHVzaF9iYWNrKG11bHRpdHlwZSh4KSk7CiAgICAgICAgcmV0dXJuICp0aGlzOwogICAgfQp9OwoKdm9pZCBwcmludChjb25zdCBoZWxwZXImIGgpCnsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgaC5hcnIuc2l6ZSgpOyBpKyspCiAgICB7CiAgICAgICAgY29uc3QgbXVsdGl0eXBlJiB4ID0gaC5hcnJbaV07CgogICAgICAgIHN3aXRjaCAoeC50eXBlKQogICAgICAgIHsKICAgICAgICBjYXNlIElOVDoKICAgICAgICAgICAgY291dCA8PCB4LnZhbC5pIDw8IGVuZGw7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgRE9VQkxFOgogICAgICAgICAgICBjb3V0IDw8IHgudmFsLmQgPDwgZW5kbDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSBDSEFSOgogICAgICAgICAgICBjb3V0IDw8IHgudmFsLmMgPDwgZW5kbDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSBTVFJJTkc6CiAgICAgICAgICAgIGNvdXQgPDwgeC52YWwucyA8PCBlbmRsOwogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICB9Cn0KCiNkZWZpbmUgUFJJTlQoLi4uKSBwcmludCgoaGVscGVyKCksIF9fVkFfQVJHU19fKSkKCmludCBtYWluKCkKewogICAgUFJJTlQoMiwgNC4yLCAnYScsICJIZWxsbyIpOwp9