[#boost-urls-params_base-get_or]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/params_base.adoc[params&lowbar;base]::get&lowbar;or
:relfileprefix: ../../../
:mrdocs:

Return the value for a key or a fallback

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/params_base.hpp#Lundefined[boost&sol;url&sol;params&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
std::string
get&lowbar;or(
    core::string&lowbar;view key,
    core::string&lowbar;view value = &lcub;&rcub;,
    xref:boost/urls/ignore_case_param.adoc[ignore&lowbar;case&lowbar;param] ic = &lcub;&rcub;) const;
----

== Description

This convenience function searches for the first parameter matching `key` and returns its decoded value&period; If no parameter with the specified key exists, the provided fallback `value` is returned instead&period; When the key is found but the parameter has no value, an empty string is returned&period;

== 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&hyphen;&gt;buffer()&period;size()`&period;

== Exception Safety

Calls to allocate may throw&period;

== Return Value

The decoded value or the fallback&period;

== Parameters

[cols="1,4"]
|===
|Name|Description

| *key*
| The key to match&period;
| *value*
| The fallback string returned when no matching key exists&period; If this parameter is omitted, an empty string is used&period;
| *ic*
| Optional case&hyphen;insensitive compare indicator&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
