| Home | Libraries | People | FAQ | More

##### write (2 of 2 overloads)

Write all output from a BuffersGenerator to a stream.

###### Synopsis

Defined in header `<boost/beast/core/buffers_generator.hpp>`

    template<
        class SyncWriteStream,
        class BuffersGenerator>
    std::size_t
    write(
        SyncWriteStream& stream,
        BuffersGenerator&& generator);

###### Description

This function is used to write all of the buffers generated by a caller-provided BuffersGenerator to a stream. The call will block until one of the following conditions is true:

- A call to the generator's `is_done` returns `false`.
- An error occurs.

This operation is implemented in terms of one or more calls to the stream's `write_some` function.

###### Parameters

Name | Description
--- | ---
`stream` | The stream to which the data is to be written. The type must support the SyncWriteStream concept.
`generator` | The generator to use.

###### Return Value

The number of bytes written to the stream.

###### Exceptions

Type | Thrown On
--- | ---
`system_error` | Thrown on failure.

###### See Also

BuffersGenerator