Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

string_param

A function parameter which efficiently converts to string.

Synopsis

Defined in header <boost/beast/core/string_param.hpp>

class string_param
Member Functions

Name

Description

operator string_view const

Implicit conversion to string_view.

operator=

Copy assignment (disallowed)

str

Returns the contained string.

string_param

Copy constructor (disallowed)

Constructor.

Description

This is used as a function parameter type to allow callers notational convenience: objects other than strings may be passed in contexts where a string is expected. The conversion to string is made using operator<< to a non-dynamically allocated static buffer if possible, else to a std::string on overflow. To use it, modify your function signature to accept string_param and then extract the string inside the function:

void print(string_param s)
{
    std::cout << s.str();
}

Convenience header <boost/beast/core.hpp>


PrevUpHomeNext