Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.15 KB

op_plus_assign.md

File metadata and controls

63 lines (45 loc) · 1.15 KB

operator+=

  • chrono[meta header]
  • std::chrono[meta namespace]
  • duration[meta class]
  • function[meta id-type]
  • cpp11[meta cpp]
duration& operator+=(const duration& d);           // C++11
constexpr duration& operator+=(const duration& d); // C++17

概要

現在の値に、他のdurationの値を足す

効果

rep_ += d.count()

戻り値

*this

#include <iostream>
#include <chrono>

using std::chrono::duration;
using std::nano; using std::micro;

int main()
{
  duration<int, nano> d1(2);
  duration<int, micro> d2(3);

  d1 += d2;

  std::cout << d1.count() << std::endl;
}
  • nano[link /reference/ratio/si_prefix.md]
  • micro[link /reference/ratio/si_prefix.md]
  • count()[link count.md]

出力

3002

バージョン

言語

  • C++11

処理系

  • GCC: 4.5.1 [mark verified], 4.6.1 [mark verified]
  • Visual C++: 2012 [mark verified], 2013 [mark verified], 2015 [mark verified]

参照