Skip to content

Latest commit

 

History

History
66 lines (51 loc) · 1.58 KB

File metadata and controls

66 lines (51 loc) · 1.58 KB

operator==

  • chrono[meta header]
  • std::chrono[meta namespace]
  • function template[meta id-type]
  • cpp11[meta cpp]
namespace std {
namespace chrono {
  template <class Rep1, class Period1, class Rep2, class Period2>
  constexpr bool operator==(const duration<Rep1, Period1>& lhs,
                            const duration<Rep2, Period2>& rhs); // (1) C++11
}}

概要

等値比較を行う

戻り値

2つのdurationの単位を合わせた上で、count()の等値比較を行う。

using ct = common_type<decltype(lhs), decltype(rhs)>::type;
return ct(lhs).count() == ct(rhs).count();
  • common_type[link /reference/type_traits/common_type.md]
  • count()[link /reference/chrono/duration/count.md]

備考

  • この演算子により、以下の演算子が使用可能になる (C++20):
    • operator!=

#include <cassert>
#include <chrono>

using namespace std::chrono;

int main()
{
  const bool result = seconds(3) == seconds(3);
  assert(result);
}
  • ==[color ff0000]

出力

バージョン

言語

  • C++11

処理系

参照