Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 1.51 KB

File metadata and controls

69 lines (52 loc) · 1.51 KB

operator<=

  • array[meta header]
  • std[meta namespace]
  • function template[meta id-type]
  • cpp11[meta cpp]
namespace std {
  // operator<=>により、以下の演算子が使用可能になる (C++20)
  template <class T, size_t N>
  bool operator<=(const array<T, N>& x, const array<T, N>& y);           // C++11

  template <class T, size_t N>
  constexpr bool operator<=(const array<T, N>& x, const array<T, N>& y); // C++20
}

概要

arrayにおいて、左辺が右辺以下かを判定する。

戻り値

!(x > y)

計算量

線形時間

#include <iostream>
#include <array>

int main ()
{
  std::array<int, 3> x = {1, 2, 3};
  std::array<int, 3> y = {4, 5, 6};

  if (x <= y) {
    std::cout << "less equal" << std::endl;
  }
  else {
    std::cout << "greater" << std::endl;
  }
}

出力

less equal

バージョン

言語

  • C++11

処理系

  • Clang: ??
  • GCC: 4.7.0 [mark verified]
  • ICC: ??
  • Visual C++: 2008 (std::tr1) [mark verified], 2010 [mark verified], 2012 [mark verified]

参照