#include <iostream>
template <typename T1, typename T2>
struct gattai2{
T1 a;
T2 b;
decltype(b(a())) operator ()() { return b(a()); }
};
template <typename T>
struct gattai1{
T a;
decltype(a()) operator ()() { return a(); }
template <typename T2>
friend gattai2<T, T2> operator +(const gattai1<T> &g, const T2 &b){
return {g.a, b};
}
};
struct gattai{
template <typename T>
friend gattai1<T> operator +(const gattai &g, const T &a){
return {a};
}
};
int main(){
auto atama = [](){ return 1; };
auto mune = [](int i){ return "tekitou"; };
auto robo = gattai() + atama + mune;
std::cout << robo() << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogCnRlbXBsYXRlIDx0eXBlbmFtZSBUMSwgdHlwZW5hbWUgVDI+CnN0cnVjdCBnYXR0YWkyewogICAgVDEgYTsKICAgIFQyIGI7CiAgICBkZWNsdHlwZShiKGEoKSkpIG9wZXJhdG9yICgpKCkgeyByZXR1cm4gYihhKCkpOyB9Cn07CiAKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CnN0cnVjdCBnYXR0YWkxewogICAgVCBhOwogICAgZGVjbHR5cGUoYSgpKSBvcGVyYXRvciAoKSgpIHsgcmV0dXJuIGEoKTsgfQogCiAgICB0ZW1wbGF0ZSA8dHlwZW5hbWUgVDI+CiAgICBmcmllbmQgZ2F0dGFpMjxULCBUMj4gb3BlcmF0b3IgKyhjb25zdCBnYXR0YWkxPFQ+ICZnLCBjb25zdCBUMiAmYil7CiAgICAgICAgcmV0dXJuIHtnLmEsIGJ9OwogICAgfQp9OwogCnN0cnVjdCBnYXR0YWl7CiAgICB0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4KICAgIGZyaWVuZCBnYXR0YWkxPFQ+IG9wZXJhdG9yICsoY29uc3QgZ2F0dGFpICZnLCBjb25zdCBUICZhKXsKICAgICAgICAgICAgcmV0dXJuIHthfTsKICAgIH0KfTsKIAppbnQgbWFpbigpewogICAgYXV0byBhdGFtYSA9IFtdKCl7IHJldHVybiAxOyB9OwogICAgYXV0byBtdW5lID0gW10oaW50IGkpeyByZXR1cm4gInRla2l0b3UiOyB9OwogICAgYXV0byByb2JvID0gZ2F0dGFpKCkgKyBhdGFtYSArIG11bmU7CiAgICBzdGQ6OmNvdXQgPDwgcm9ibygpIDw8IHN0ZDo6ZW5kbDsKfQ==