名前空間
変種
操作

std::chrono::duration

提供: cppreference.com
< cpp‎ | chrono


 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
ペアとタプル
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
フォワード、スワップ、および移動
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
 
std::chrono::duration
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
duration::duration
duration::operator=
duration::count
duration::zero
duration::min
duration::max
duration::operator+
duration::operator-
duration::operator++
duration::operator--
duration::operator+=
duration::operator-=
duration::operator*=
duration::operator/=
duration::operator%=
非メンバ関数
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
common_type
operator+
operator-
operator*
operator/
operator%
operator==
operator!=
operator<
operator<=
operator>
operator>=
duration_cast
ヘルパークラス
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
treat_as_floating_point
duration_values
 
Defined in header <chrono>
template<

    class Rep,
    class Period = std::ratio<1>

> class duration;
(C + + 11以来)

Class template std::chrono::duration represents a time interval.

It consists of a count of ticks of type Rep and a tick period, where the tick period is a compile-time rational constant representing the number of seconds from one tick to the next.

The only data stored in a duration is a tick count of type Rep. If Rep is floating point, then the duration can represent fractions of ticks. Period is included as part of the duration's type, and is only used when converting between different durations.

目次

[編集] メンバータイプ

メンバー·タイプ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
rep Rep, an arithmetic type representing the number of ticks
period Period, a std::ratio representing the tick period (i.e. the number of seconds per tick)

[編集] メンバ関数

新しいデュレーションを構築します
Original:
constructs new duration
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
内容が割り当てられます
Original:
assigns the contents
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
刻みの数を返します
Original:
returns the count of ticks
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
[静的]
returns the special duration value zero
(公共の静的メンバ関数) [edit]
[静的]
特別期間値minを返します
Original:
returns the special duration value min
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(公共の静的メンバ関数) [edit]
[静的]
特別期間の値maxを返す
Original:
returns the special duration value max
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(公共の静的メンバ関数) [edit]
単項+と単項を実装しています - 。。。
Original:
implements unary + and unary -
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
インクリメントまたはデクリメントするティック数
Original:
increments or decrements the tick count
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
2期間の間に複合代入を実装しています
Original:
implements compound assignment between two durations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]

[編集] Non-member types

タイプ
Original:
Type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
std::chrono::nanoseconds duration type with Period std::nano
std::chrono::microseconds duration type with Period std::micro
std::chrono::milliseconds duration type with Period std::milli
std::chrono::seconds duration type with Period std::ratio<1>
std::chrono::minutes duration type with Period std::ratio<60>
std::chrono::hours duration type with Period std::ratio<3600>

[編集] 非メンバ関数

std::common_type形質を専門としています
Original:
specializes the std::common_type trait
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレートの特殊化の2つの値を比較します) [edit]
引数として期間との間で演算を実装しています
Original:
implements arithmetic operations with durations as arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
2期間を比較します
Original:
compares two durations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
異なる目盛間隔で、別の期間に変換します
Original:
converts a duration to another, with a different tick interval
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]

[編集] ヘルパークラス

indicates that a duration is convertible to duration with different tick period
(クラステンプレート)
constructs zero, min, and max values of a tick count of given type
(クラステンプレート)

[編集]

This example shows how to define several custom duration types and convert between types:

#include <iostream>
#include <chrono>
 
int main()
{
    typedef std::chrono::duration<int, std::ratio<1, 100000000>> shakes;
    typedef std::chrono::duration<int, std::centi> jiffies;
    typedef std::chrono::duration<float, std::ratio<12096,10000>> microfortnights;
    typedef std::chrono::duration<float, std::ratio<3155,1000>> nanocenturies;
 
    std::chrono::seconds sec(1);
 
    std::cout << "1 second is:\n";
 
    std::cout << std::chrono::duration_cast<shakes>(sec).count()
              << " shakes\n";
    std::cout << std::chrono::duration_cast<jiffies>(sec).count()
              << " jiffies\n";
    std::cout << std::chrono::duration_cast<microfortnights>(sec).count()
              << " microfortnights\n";
    std::cout << std::chrono::duration_cast<nanocenturies>(sec).count()
              << " nanocenturies\n";
}

Output:

1 second is:
100000000 shakes
100 jiffies
0.82672 microfortnights
0.316957 nanocenturies