[#boost-urls-param_pct_view-2constructor-05]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/param_pct_view.adoc[param&lowbar;pct&lowbar;view]::param&lowbar;pct&lowbar;view
:relfileprefix: ../../../
:mrdocs:


Constructor

== Synopsis


Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/param.hpp#L783[boost&sol;url&sol;param&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class OptionalString&gt;
param&lowbar;pct&lowbar;view(
    xref:boost/urls/pct_string_view.adoc[pct&lowbar;string&lowbar;view] key,
    OptionalString const& value);
----

== Description


This constructs a parameter with a key        and optional value, which may both        contain percent escapes&period;

The new key and value reference        the same corresponding underlying        character buffers&period;

Ownership of the buffers is not transferred&semi;        the caller is responsible for ensuring that        the assigned buffers remain valid until        they are no longer referenced&period;


=== Example

[,cpp]
----
param_pct_view qp( "key", optional<core::string_view>("value") );
----

=== Postconditions

[,cpp]
----
this->key.data() == key.data() && this->value->data() == value->data() && this->has_value == true
----

=== Complexity

Linear in `key&period;size() &plus; value&hyphen;&gt;size()`&period;


=== Exception Safety

Exceptions thrown on invalid input&period;



== Exceptions


|===
| Name | Thrown on

| `system&lowbar;error`
| `key` or `value` contains an invalid percent&hyphen;encoding&period;


|===

== Template Parameters


|===
| Name | Description

| *OptionalString*
| An optional        `core&colon;&colon;string&lowbar;view` type, such as        `boost&colon;&colon;optional&lt;core&colon;&colon;string&lowbar;view&gt;` or        `std&colon;&colon;optional&lt;core&colon;&colon;string&lowbar;view&gt;`&period;


|===

== Parameters


|===
| Name | Description

| *key,*
| value The key and value to set&period;


|===



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