
11 Sep
2012
11 Sep
'12
8:20 p.m.
Am 11.09.2012 17:43, schrieb Eugene Yakubovich:
Maybe we can change behavior so that generator's constructor does not invoke the generator-function, only operator() does. And change operator() to return optional<R> instead of R. The usage can then be:
gen_t g(foo); while( optional<X> val = g() ) { // use val.get() } what would be the benefit?
This would eliminate the "early destruction" problem described before. The generator would end up not storing a value (which it currently does in detail::generator_resume::result_) and operator() would just return whatever the generator-function yielded or optional<none> if the generator-function exited.
changed in git-repo regards, Oliver