std::chrono::duration<Rep,Period>:: operator+=, -=, *=, /=, %=
From cppreference.net
| (1) | ||
|
duration
&
operator
+
=
(
const
duration
&
d
)
;
|
(C++11以降)
(constexprはC++17以降) |
|
| (2) | ||
|
duration
&
operator
-
=
(
const
duration
&
d
)
;
|
(C++11以降)
(constexprはC++17以降) |
|
| (3) | ||
|
duration
&
operator
*
=
(
const
rep
&
rhs
)
;
|
(C++11以降)
(constexprはC++17以降) |
|
| (4) | ||
|
duration
&
operator
/
=
(
const
rep
&
rhs
)
;
|
(C++11以降)
(constexprはC++17以降) |
|
| (5) | ||
|
duration
&
operator
%
=
(
const
rep
&
rhs
)
;
|
(C++11以降)
(constexprはC++17以降) |
|
| (6) | ||
|
duration
&
operator
%
=
(
const
duration
&
rhs
)
;
|
(C++11以降)
(constexprはC++17以降) |
|
同じ周期を持つ2つの期間間、または期間とティックカウント値の間で複合代入を実行します。
rep_
がこのdurationオブジェクト内のティック数を保持するメンバ変数である場合、
1)
次と同等:
rep_
+
=
d.
count
(
)
;
return
*
this
;
.
2)
次と同等:
rep_
-
=
d.
count
(
)
;
return
*
this
;
.
3)
次と同等
rep_
*
=
rhs
;
return
*
this
;
.
4)
次と同等
rep_
/
=
rhs
;
return
*
this
;
.
5)
次と同等:
rep_
%
=
rhs
;
return
*
this
;
.
6)
次と同等:
rep_
%
=
d.
count
(
)
;
return
*
this
;
.
目次 |
パラメータ
| d | - | 演算子の右側の期間 |
| rhs | - | 演算子の右側のティック数 |
戻り値
この期間への参照(変更後)。
例
このコードを実行
#include <chrono> #include <iostream> int main() { std::chrono::minutes m(11); m *= 2; m += std::chrono::hours(10); // hours implicitly convert to minutes std::cout << m.count() << " minutes equals " << std::chrono::duration_cast<std::chrono::hours>(m).count() << " hours and "; m %= std::chrono::hours(1); std::cout << m.count() << " minutes\n"; }
出力:
622 minutes equals 10 hours and 22 minutes
関連項目
|
ティックカウントをインクリメントまたはデクリメントする
(public member function) |
|
|
期間を引数とする算術演算を実装する
(function template) |