Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 933 Bytes

op_less_equal.md

File metadata and controls

51 lines (37 loc) · 933 Bytes

operator<=

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

概要

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

戻り値

!(x > y)

計算量

線形時間

#include <iostream>
#include <list>

int main ()
{
  std::list<int> ls1 = {1, 2, 3};
  std::list<int> ls2 = {4, 5, 6};

  std::cout << std::boolalpha;

  std::cout << (ls1 <= ls2) << std::endl;
}

出力

true

参照