:relfileprefix: ../../../
[#F7DFD04D205018BACD8F7CC6770E55CD896A7E72]

= Function url_base::set_query

pass:v,q[Set the query]


== Synopsis

Declared in header `</boost/url/url_base.hpp#L1973[boost/url/url_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/url_base.adoc[url_base]&
set_query(string_view s);
----

== Description

pass:v,q[This sets the query to the string, which] pass:v,q[can be empty.] pass:v,q[An empty query is distinct from having]
pass:v,q[no query.]
pass:v,q[Reserved characters in the string are]
pass:v,q[percent-escaped in the result.]

=== Example
[,cpp]
----
assert( url( "http://example.com" ).set_query( "id=42" ).query() == "id=42" );
----

=== Postconditions
[,cpp]
----
this->has_query() == true && this->query() == s
----

=== Exception Safety
pass:v,q[Strong guarantee.]
pass:v,q[Calls to allocate may throw.]

=== BNF
[,cpp]
----
query           = *( pchar / "/" / "?" )

query-param     = key [ "=" value ]
query-params    = [ query-param ] *( "&" query-param )
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.4[3.4.  Query (rfc3986)]

* link:https://en.wikipedia.org/wiki/Query_string[Query string (Wikipedia)]



== Return Value

* `` 


== Parameters

|===
| Name | Type 

| *s*
| `string_view`

|===



