Edit

Share via


weekday_last class

Represents the last weekday of a month.

Syntax

class weekday_last; // C++20

Remarks

weekday_last is a trivially copyable and standard-layout class type.

Members

Constructor

Name Description
weekday_last Constructs a weekday_last with the specified weekday value.

Functions

Name Description
ok Check if the weekday value is valid.
weekday Get the weekday value.

Operators

Name Description
operator== Determine whether two weekday_last instances are equal.
operator<< Output a weekday_last to the specified stream.

Requirements

Header: <chrono> Since C++20

Namespace: std::chrono

Compiler Option: /std:c++latest

Constructor

Constructs a weekday_last that is initialized with a weekday value.

constexpr explicit weekday_last(const chrono::weekday& wd) noexcept; // C++20

Parameters

wd
The weekday value for the created weekday_last class.

Remarks

It's easier to construct a weekday_last using the weekday operator[]. See the example below.

ok

Check if the value stored in this weekday_last is in the valid range.

constexpr bool ok() const noexcept;

Return value

true if the week weekday value is in the valid range. Otherwise, false.

weekday

Get the weekday value.

constexpr chrono::weekday weekday() const noexcept;

Return value

The weekday value.

Example

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    constexpr auto wdl{ Monday[last] }; // wdl is the last Monday of an unspecified month
    std::cout << wdl.weekday() << "\n";

    return 0;
}
Mon

See also

<chrono>
weekday class
weekday_indexed class
Header Files Reference