#1300·cpr

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

Author: actsdCreated Mar 5, 2026Updated Mar 6, 2026
LabelsFeature :sparkles:Needs Investigation :mag:

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?