With the diverts in M4 it is possible to expand a macro in several places in a code - for example, when a property of a Class is expanded, the accessors and the data layout can be written to different places. After the last deffinition, this sections can be undiverted, that means a secentiel file will be written
The ostringstream allocates the memory it needs, when its feed with new code. The undivertion is simply done by writing the resultung sting in the file.