Thoughts and Opinions on Coding and Tech
I wanted to play with generators and coroutines in C++. Coroutines are a feature I really like in python. In a nutshell a coroutine is a function that can suspend itself and return a value on each suspend. This is called
yielding. The next iteration of C++ will include coroutines and add the keyword
co_yieldto perform yielding. In this post I’ll show my implementation of a coroutine-like generator.
To simplify and RAII-fy linux file handles I’ve created a super small C++ library “simplyfile” some time ago. The library is actually not special and you could imagine how the code looks like (close on destruction and some moves). However, there are two reasons I prefer dealing with files encapsulated in simplyfile’s handles: