#include <iostream>
#include <tuple>
#include <vector>
struct Stream
{
template<class T> Stream& operator>>(T& t) {
t.Serialize(*this);
return *this;
}
template<class T> Stream& operator&(T& t) {
*this >> t;
return *this;
}
};
template<class T> Stream& operator>>(Stream& stream, std::vector<T>& vec) {
T t;
stream >> t;
vec.push_back(std::move(t));
return stream;
}
template<std::size_t I, std::size_t S, class ... T> struct TupleRecv {
void inline operator()(Stream& stream, std::tuple<T ...>& tuple) {
stream >> std::get<I>(tuple);
TupleRecv<I + 1, S, T ...>()(stream, tuple);
}
};
template<std::size_t S, class ... T> struct TupleRecv<S, S, T ...> {
void inline operator()(Stream&, std::tuple<T ...>&) {}
};
template<class ... T> Stream& operator>>(Stream& stream, std::tuple<T ...>& tuple) {
TupleRecv<0, std::tuple_size<std::tuple<T ...>>::value, T ...>()(stream, tuple);
return stream;
}
Stream& operator>>(Stream& stream, int& i) {
// do i
i = 9;
return stream;
}
int main(int,char**) {
Stream s;
std::vector<std::tuple<int>> data;
s >> data;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDx2ZWN0b3I+CgpzdHJ1Y3QgU3RyZWFtCnsKICAgIHRlbXBsYXRlPGNsYXNzIFQ+IFN0cmVhbSYgb3BlcmF0b3I+PihUJiB0KSB7CgkJdC5TZXJpYWxpemUoKnRoaXMpOwoJCXJldHVybiAqdGhpczsKCX0KCgl0ZW1wbGF0ZTxjbGFzcyBUPiBTdHJlYW0mIG9wZXJhdG9yJihUJiB0KSB7CgkJKnRoaXMgPj4gdDsKCQlyZXR1cm4gKnRoaXM7Cgl9Cn07Cgp0ZW1wbGF0ZTxjbGFzcyBUPiBTdHJlYW0mIG9wZXJhdG9yPj4oU3RyZWFtJiBzdHJlYW0sIHN0ZDo6dmVjdG9yPFQ+JiB2ZWMpIHsKCVQgdDsKCXN0cmVhbSA+PiB0OwoJdmVjLnB1c2hfYmFjayhzdGQ6Om1vdmUodCkpOwoJcmV0d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