Skip to content

Some Get() arguments in a more direct way, e.g. cpr::Parameters{} directly from std::map without extra steps #1300

@actsd

Description

@actsd

Hello

I notice that when trying something like:

cpr::Response r = cpr::Get(cpr::Url{u}, cpr::Parameters{p});

Where p is a map (function argument), for example a std::map, that can contain 0, 1, or multiple key-value parameters, then it shows an error:

"""
'': cannot convert from 'initializer list' to 'cpr::Parameters'

"""

Current way to work this

For now the way to work has been explicitly converting the map to a cpr::Parameters, which requires an extra step, for example:

// …

cpr::Parameters p_cpr{};

for (const auto& [k, v] : p) {
    p_cpr.Add({k, v});
}

cpr::Response r = cpr::Get(cpr::Url{u}, cpr::Parameters{p_cpr});

// ...

Is there any way to work this kind of cases with c++ applicable elements (in this case a std::map)? just as an url can come from a std::string variable?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions