次の方法で共有


hh_mm_ss クラス

std::chrono::duration を、Duration テンプレート パラメーターによって決められた分割の有効桁数で時間:分:秒に分割します。 このクラスは、主に書式設定ツールとして使用されます。

Duration は、std::chrono::duration の特殊化であることが必要です。

構文

template<class Duration> class hh_mm_ss; // C++20

メンバー

名前 説明
コンストラクター hh_mm_ss を構築します。
is_negative 期間が負であるかどうかを示します。
hours 時間の値を取得します。
分の値を取得します。
seconds 秒の値を取得します。
subseconds 秒未満の値を取得します。
to_duration duration_cast<precision> を返します。
hh_mm_ss::operator precision この hh_mm_ss の有効桁数を返します。

非メンバー

名前 説明
hh_mm_ss::operator<< 指定したストリームに hh_mm_ss を出力します。

必要条件

ヘッダー:<chrono>

名前空間std::chrono:

コンパイラ オプション:/std:c++latest

hh_mm_ss::hh_mm_ss コンストラクター

hh_mm_ss を構築します。

constexpr explicit hh_mm_ss(Duration d);

パラメーター

d
有効桁数が duration<common_type_t<Duration::rep, seconds::rep>, ratio<1, 10fractional_width>> として定義された Durationd を表す hh_mm_ss を構築します

解説

treat_as_floating_point_v<precision::rep>true の場合、有効桁数は abs(d)-hours()-minutes()-seconds() で初期化されます。 そうでない場合、有効桁数は duration_cast<precision>(abs(d)-hours()-minutes()-seconds()) で初期化されます

hh_mm_ss::is_negative

期間が負であるかどうかを取得します。

constexpr bool is_negative() const noexcept;

戻り値

hh_mm_ss 値が負の場合は true。 それ以外の場合は false

hh_mm_ss::hours

この hh_mm_ss の時間の部分を取得します。

constexpr chrono::hours hours() const noexcept;

戻り値

この hh_mm_sshours 値。

hh_mm_ss::minutes

この hh_mm_ss の分の部分を取得します。

constexpr chrono::minutes minutes() const noexcept;

戻り値

この hh_mm_ssminutes 値。

hh_mm_ss::seconds

この hh_mm_ss の秒の部分を取得します。

constexpr chrono::seconds seconds() const noexcept;

戻り値

この hh_mm_ssseconds 値。

hh_mm_ss::subseconds

この hh_mm_ss の秒未満の部分を取得します。

constexpr precision subseconds() const noexcept;

戻り値

この hh_mm_sssubseconds 値。
std::chrono::treat_as_floating_point_v<precision::rep>true の場合、これは abs(d)-hours()-minutes()-seconds() として計算されます。 それ以外の場合は、std::chrono::duration_cast<precision>(abs(d)-hours()-minutes()-seconds()) として計算されます

hh_mm_ss::operator precision

constexpr explicit operator precision() const noexcept;

戻り値

to_duration を返します

hh_mm_ss::to_duration

constexpr precision to_duration() const noexcept;

戻り値

is_negtrue の場合、-(h+m+s+ss) を返します。 それ以外の場合、h+m+s+ss を返します。

関連項目

<chrono>
ヘッダー ファイル リファレンス