python like generator in C++