最終更新日時(UTC):
が更新

履歴 編集

function template
<forward_list>

std::operator<(C++11)

namespace std {
  // operator<=>により、以下の演算子が使用可能になる (C++20)
  template <class T, class Allocator>
  bool operator<(const forward_list<T, Allocator>& x,
                 const forward_list<T, Allocator>& y); // (1) C++11
}

概要

forward_listにおいて、左辺が右辺より小さいかの判定を行う。

要件

T<比較可能であること。その<が全順序関係を持っていること。

戻り値

計算量

要素数に対して線形時間。

#include <iostream>
#include <forward_list>

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

  std::cout << std::boolalpha;

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

出力

true

バージョン

言語

  • C++11

処理系

参照