[#boost-urls-params_base-get_or] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/params_base.adoc[params_base]::get_or :relfileprefix: ../../../ :mrdocs: Return the value for a key or a fallback == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/params_base.hpp#Lundefined[boost/url/params_base.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- std::string get_or( core::string_view key, core::string_view value = {}, xref:boost/urls/ignore_case_param.adoc[ignore_case_param] ic = {}) const; ---- == Description This convenience function searches for the first parameter matching `key` and returns its decoded value. If no parameter with the specified key exists, the provided fallback `value` is returned instead. When the key is found but the parameter has no value, an empty string is returned. == Example [,cpp] ---- url_view u( "/path?first=John&last=Doe" ); assert( u.params().get_or( "first", "n/a" ) == "John" ); assert( u.params().get_or( "missing", "n/a" ) == "n/a" ); ---- == Complexity Linear in `this‐>buffer().size()`. == Exception Safety Calls to allocate may throw. == Return Value The decoded value or the fallback. == Parameters [cols="1,4"] |=== |Name|Description | *key* | The key to match. | *value* | The fallback string returned when no matching key exists. If this parameter is omitted, an empty string is used. | *ic* | Optional case‐insensitive compare indicator. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#