[#mp_units-check_in_range]
= xref:mp_units.adoc[mp&lowbar;units]::check&lowbar;in&lowbar;range
:relfileprefix: ../
:mrdocs:

Policy that checks the value is within &lsqb;min, max&rsqb;and reports violations&period;

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;overflow&lowbar;policies&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;xref:mp_units/Quantity.adoc[Quantity] Q&gt;
struct check&lowbar;in&lowbar;range;
----

== Description

If the quantity&apos;s representation type has a `constraint&lowbar;violation&lowbar;handler` specialization, the handler&apos;s `on&lowbar;violation()` is called on out&hyphen;of&hyphen;bounds values (providing guaranteed enforcement regardless of build mode)&period; Otherwise, falls back to `MP&lowbar;UNITS&lowbar;EXPECTS`, which may be disabled in release builds&period;

Example&colon;

[,cpp]
----
{cpp}
 // With constrained<double, throw_policy> rep → throws std::domain_error on violation
 // With plain double rep → asserts via MP_UNITS_EXPECTS (may be no-op in release)
 template<>
 constexpr auto quantity_bounds<equator> = check_in_range{-90 * deg, 90 * deg};
----
== Member Functions

[cols=1]
|===
| Name
| xref:mp_units/check_in_range/operator_call.adoc[`operator()`] 
|===

== Data Members

[cols=1]
|===
| Name
| xref:mp_units/check_in_range/max.adoc[`max`] 
| xref:mp_units/check_in_range/min.adoc[`min`] 
|===


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