month_weekday class

Represents the nth weekday of a specific month.

Syntax

class month_weekday; // C++20

Remarks

The year is unspecified.
month_weekday is a trivially copyable and standard-layout class type.

Members

Name Description
Constructor Construct a month_weekday with the specified month and weekday.
month Return the month value.
ok Check if the month_weekday is valid.
weekday_indexed Return the weekday index.

Non-members

Name Description
operator== Determine whether two months are equal.
operator<< Output a month_weekday to the given stream.

Requirements

Header: <chrono> (since C++20)

Namespace: std::chrono

Compiler Option: /std:c++latest

Constructor

Constructs a month_weekday. The month and weekday aren't initialized.

constexpr month_weekday(const month& m, const weekday_indexed& wdi) noexcept;

Parameters

m
Construct a month_weekday with a month value of m.

wdi
Construct a month_weekday with a weekday value of wdi.

Remarks: Constructor

For information about C++20 syntax to specify dates, see operator/

Example: Create a month_weekday

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

using namespace std::chrono;

int main()
{
    month_weekday mw{ July/Monday[1] };
    std::cout << mw << '\n';

    // Another way to create a month_weekday
    month_weekday mw2 = February / Tuesday[3];
    std::cout << mw2;

    return 0;
}
Jul/Mon[1]
Feb/Tue[3]

month

Get the month value.

constexpr month month() const noexcept;

Return value

The month value.

ok

Check if the value stored in this month_weekday is valid.

constexpr bool ok() const noexcept;

Return value

true if the month_weekday value is valid. Otherwise, false.
A month_weekday is valid if both the month is valid and the weekday_indexed value is valid.

weekday_indexed

Return the weekday of the month value.

constexpr weekday_indexed weekday_indexed() const noexcept;

Return value

The weekday of the month.

See also

<chrono>
month class
month_day Class
month_day_last Class
month_weekday_last class