Skip to content

Latest commit

 

History

History
73 lines (58 loc) · 1.69 KB

op_less_equal.md

File metadata and controls

73 lines (58 loc) · 1.69 KB

operator<=

  • iterator[meta header]
  • std[meta namespace]
  • function template[meta id-type]
  • cpp11[meta cpp]
namespace std {
  template <class Iterator1, class Iterator2>
  bool operator<=(const move_iterator<Iterator1>& x,
                  const move_iterator<Iterator2>& y);           // C++11

  template <class Iterator1, class Iterator2>
  constexpr bool operator<=(const move_iterator<Iterator1>& x,
                            const move_iterator<Iterator2>& y); // C++17
}

概要

2つのmove_iteratorオブジェクトにおいて、左辺が右辺以下かを判定する。

戻り値

return !(y < x);

#include <iostream>
#include <vector>
#include <memory>
#include <algorithm>
#include <iterator>

int main()
{
  std::vector<std::unique_ptr<int>> v;
  for (int i = 0; i < 5; ++i)
    v.emplace_back(new int(i));

  auto it1 = std::make_move_iterator(v.begin());
  auto it2 = std::make_move_iterator(v.begin() + 1);

  if (it1 <= it2) {
    std::cout << "less" << std::endl;
  }
  else {
    std::cout << "not less" << std::endl;
  }
}
  • v.emplace_back[link /reference/vector/vector/emplace_back.md]
  • std::make_move_iterator[link /reference/iterator/make_move_iterator.md]

出力

less

バージョン

言語

  • C++11

処理系

参照