名前空間
変種
操作

std::chrono::floor(std::chrono::duration)

提供: cppreference.com
< cpp‎ | chrono‎ | duration
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
日付と時間のユーティリティ
(C++11)
(C++11)
時刻
(C++20)



(C++20)(C++20)(C++20)(C++20)
時計
(C++20)
                                             
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
カレンダー
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
タイムゾーン
(C++20)
(C++20)
(C++20)
(C++20)
C スタイルの日付と時間
 
 
ヘッダ <chrono> で定義
template <class ToDuration, class Rep, class Period>
constexpr ToDuration floor(const duration<Rep, Period>& d);
(C++17以上)

d より小さいまたは等しい、 ToDuration で表現可能な最大の duration を返します。

この関数は、 ToDurationstd::chrono::duration の特殊化でなければ、オーバーロード解決に参加しません。

目次

[編集] 引数

d - 変換する duration

[編集] 戻り値

ToDuration 型の duration に切り捨てられた d

[編集] 実装例

template <class T> struct is_duration : std::false_type {};
template <class Rep, class Period> struct is_duration<
    std::chrono::duration<Rep, Period>> : std::true_type {};
 
template <class To, class Rep, class Period,
          class = std::enable_if_t<is_duration<To>{}>>
constexpr To floor(const duration<Rep, Period>& d)
{
    To t = std::chrono::duration_cast<To>(d);
    if (t > d)
        return t - To{1};
    return t;
}

[編集]

[編集] 関連項目

時間を異なる刻み幅を持つ別の時間に変換します
(関数テンプレート) [edit]
時間を別の時間に切り上げ変換します
(関数テンプレート) [edit]
時間を別の時間の最も近い値に丸めて変換します
(関数テンプレート) [edit]
time_point を別の time_point に切り捨て変換します
(関数テンプレート) [edit]
(C++11)(C++11)
指定された値より大きくない最も近い整数を返します
(関数) [edit]