Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 1.07 KB

File metadata and controls

62 lines (47 loc) · 1.07 KB

operator-

  • chrono[meta header]
  • std::chrono[meta namespace]
  • duration[meta class]
  • function[meta id-type]
  • cpp11[meta cpp]
constexpr common_type_t<duration> operator-() const;
  • common_type_t[link /reference/chrono/common_type.md]

概要

負の符号。

符号反転する。

戻り値

return common_type_t<duration>(-rep_);

rep_は内部で保持している値。メンバ変数名は説明用のもの

#include <iostream>
#include <chrono>

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

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

  duration<int, nano> d2 = -d1;

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

出力

2
-2

バージョン

言語

  • C++11

処理系

参照