GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::in_range(3) C++ Standard Libary std::in_range(3)

std::in_range - std::in_range


Defined in header <utility>
template< class R, class T > (since C++20)
constexpr bool in_range( T t ) noexcept;


Returns true if the value of t is in the range of values that can be represented in
R, that is, if t can be converted to R without data loss.


It is a compile-time error if either T or R is not a signed or unsigned integer type
(including standard integer type and extended integer type).


t - value to test


true if the value of t is representable in R, false otherwise.


template< class R, class T >
constexpr bool in_range( T t ) noexcept
{
return std::cmp_greater_equal(t, std::numeric_limits<R>::min()) &&
std::cmp_less_equal(t, std::numeric_limits<R>::max());
}


This function cannot be used with enums (including std::byte), char, char8_t,
char16_t, char32_t, wchar_t and bool.


Feature-test macro: __cpp_lib_integer_comparison_functions

// Run this code


#include <utility>
#include <iostream>


int main()
{
std::cout << std::boolalpha;


std::cout << std::in_range<std::size_t>(-1) << '\n';
std::cout << std::in_range<std::size_t>(42) << '\n';
}


false
true


ranges::min returns the smaller of the given values
(C++20) (niebloid)
ranges::max returns the greater of the given values
(C++20) (niebloid)
ranges::clamp clamps a value between a pair of boundary values
(C++20) (niebloid)
lerp linear interpolation function
(C++20) (function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.