URL Query params builder My goal is to create a URL query params from std::map&lt;std::string, std::string&gt;. For example, we call to_query_params( {{"one","1"},{"two","2"}} ) and we get ?one=1&amp;two=2.

Is this a good way of doing it?

std::string to_query_params(std::map&lt;std::string, std::string&gt; map)
{
    if (map.empty()){
        return "";
    }
    auto map_beg = std::begin(map);
    auto concat = [](const decltype(map)::value_type&amp; a){
                        return a.first+"="+a.second;
                    };
    std::string result("?"+concat(*map_beg));
    std::for_each(std::next(std::begin(map)), 
                  std::end(map), 
                  [&amp;](decltype(map)::value_type param){ 
                      result+="&amp;"+concat(param); 
                  });
    return result;
}
You are not performing any percent encoding of parameter names or values, which would likely lead to breakage or even a security vulnerability if the you are given parameters that contain a special character.

A std::map might not be the right type; a std::multimap may be more appropriate.