| Home | Libraries | People | FAQ | More

###### http::parser::parser (5 of 5 overloads)

Construct a parser from another parser, changing the Body type.

<h7> Synopsis </h7>

    template<
        class OtherBody,
        class... Args>
    parser(
        parser< isRequest, OtherBody, Allocator >&& parser,
        Args&&... args);

<h7> Description </h7>

This constructs a new parser by move constructing the header from another parser with a different body type. The constructed-from parser must not have any parsed body octets or initialized BodyReader, otherwise an exception is generated.

<h7> Example </h7>

    // Deferred body type commitment
    request_parser<empty_body> req0;
    ...
    request_parser<string_body> req{std::move(req0)};

If an exception is thrown, the state of the constructed-from parser is undefined.

<h7> Parameters </h7>

Name | Description
--- | ---
`parser` | The other parser to construct from. After this call returns, the constructed-from parser may only be destroyed.
`args` | Optional arguments forwarded to the message constructor.

<h7> Exceptions </h7>

Type | Thrown On
--- | ---
`std::invalid_argument` | Thrown when the constructed-from parser has already initialized a body reader.

<h7> Remarks </h7>

This function participates in overload resolution only if the other parser uses a different body type.