#include <iostream>
using namespace std;
#define TEST1 (0)
#define TEST2 (0)
#if TEST1
#include <iomanip>
#endif
template<class T>
class Unko
{
public:
Unko(ostream& (*f)(ostream&, T), T i) : func(f), value(i) { }
#if TEST2
template<class T2>
friend ostream& operator<< (ostream&, const Unko<T2>&);
private:
#endif
T value;
ostream& (*func)(ostream&, T);
};
template <class T>
ostream& operator<< (ostream& o, const Unko<T>& u) {
return (*u.func)(o, u.value);
}
ostream& unkounko(ostream& o, int i) {
#if TEST1
return o << setfill('0') << setw(10) << hex << (i * 2)
<< dec << setfill(' ');
#else
o.width(10);
o.fill('0');
o.setf(o.hex, o.basefield);
o << (i * 2);
o.fill(' ');
o.unsetf(o.basefield);
return o;
#endif
}
ostream& gerigeri(ostream& o, int i) {
return o << '(' << i << ')';
}
inline Unko<int> unko(int i) {
return Unko<int>(unkounko, i);
}
inline Unko<int> geri(int i) {
return Unko<int>(gerigeri, i);
}
ostream& abc(ostream& o) {
return o << "abc";
}
int main() {
cout << abc << unko(123) << geri(345) << abc;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBURVNUMSAoMCkKI2RlZmluZSBURVNUMiAoMCkKCiNpZiBURVNUMQojaW5jbHVkZSA8aW9tYW5pcD4KI2VuZGlmCgp0ZW1wbGF0ZTxjbGFzcyBUPgpjbGFzcyBVbmtvCnsKcHVibGljOgoJVW5rbyhvc3RyZWFtJiAoKmYpKG9zdHJlYW0mLCBUKSwgVCBpKSA6IGZ1bmMoZiksIHZhbHVlKGkpIHsgfQojaWYgVEVTVDIKCXRlbXBsYXRlPGNsYXNzIFQyPgoJZnJpZW5kIG9zdHJlYW0mIG9wZXJhdG9yPDwgKG9zdHJlYW0mLCBjb25zdCBVbmtvPFQyPiYpOwpwcml2YXRlOgojZW5kaWYKCVQgdmFsdWU7Cglvc3RyZWFtJiAoKmZ1bmMpKG9zdHJlYW0mLCBUKTsKfTsKCnRlbXBsY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