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::chrono::year::ok(3) C++ Standard Libary std::chrono::year::ok(3)

std::chrono::year::ok - std::chrono::year::ok


constexpr bool ok() const noexcept; (since C++20)


Checks if the year value stored in *this is in the valid range, i.e., [-32767,
32767].


true if the year value stored in *this is in the range [-32767, 32767]. Otherwise
false.


See the implementations in libstdc++, libc++, and Howard Hinnant's date.h.


class Year
{
short year_; /* exposition only */


public:


bool ok() const noexcept { return year_ != std::numeric_limits<short>::min(); }


/*...*/
};

// Run this code


#include <iostream>
#include <iomanip>
#include <chrono>


int main()
{
for (const int i : {2020, 0x8000, 0x8001, 0xFFFF, 0x18000}) {
const std::chrono::year y{i};
std::cout << std::boolalpha
<< "input year: " << std::setw(6) << i
<< " │ internal value: " << std::setw(7) << static_cast<int>(y)
<< " │ ok(): " << y.ok() << '\n';
}
}


input year: 2020 │ internal value: 2020 │ ok(): true
input year: 32768 │ internal value: -32768 │ ok(): false
input year: 32769 │ internal value: -32767 │ ok(): true
input year: 65535 │ internal value: -1 │ ok(): true
input year: 98304 │ internal value: -32768 │ ok(): false

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.