template<typename... args>
struct stream_op
{
unsigned int size() { return sizeof...(args); }
};
template<typename... A, typename B>
stream_op<A..., B> operator<<(stream_op<A...> a, B b)
{
// Do stuff
return stream_op<A..., B>();
}
stream_op<> empty;
#include <iostream>
int main()
{
std::cout << "length = " << (empty << 1 << 2).size() << "\n";
std::cout << "length = " << (empty << 1 << 2 << 3).size() << "\n";
std::cout << "length = " << (empty << 1 << 2 << 3 << 4).size() << "\n";
}
dGVtcGxhdGU8dHlwZW5hbWUuLi4gYXJncz4Kc3RydWN0IHN0cmVhbV9vcAp7CiAgICB1bnNpZ25lZCBpbnQgc2l6ZSgpIHsgcmV0dXJuIHNpemVvZi4uLihhcmdzKTsgfQp9OwoKdGVtcGxhdGU8dHlwZW5hbWUuLi4gQSwgdHlwZW5hbWUgQj4Kc3RyZWFtX29wPEEuLi4sIEI+IG9wZXJhdG9yPDwoc3RyZWFtX29wPEEuLi4+IGEsIEIgYikKewogICAgLy8gRG8gc3R1ZmYKICAgIHJldHVybiBzdHJlYW1fb3A8QS4uLiwgQj4oKTsKfQoKc3RyZWFtX29wPD4gZW1wdHk7CgojaW5jbHVkZSA8aW9zdHJlYW0+CmludCBtYWluKCkKewogICAgc3RkOjpjb3V0IDw8ICJsZW5ndGggPSAiIDw8IChlbXB0eSA8PCAxIDw8IDIpLnNpemUoKSA8PCAiXG4iOwogICAgc3RkOjpjb3V0IDw8ICJsZW5ndGggPSAiIDw8IChlbXB0eSA8PCAxIDw8IDIgPDwgMykuc2l6ZSgpIDw8ICJcbiI7CiAgICBzdGQ6OmNvdXQgPDwgImxlbmd0aCA9ICIgPDwgKGVtcHR5IDw8IDEgPDwgMiA8PCAzIDw8IDQpLnNpemUoKSA8PCAiXG4iOwp9Cg==