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

履歴 編集

function template
<string_view>

std::operator>(C++17)

namespace std {
  // operator<=>により、以下の演算子が使用可能になる (C++20)
  template <class CharT, class Traits>
  constexpr bool operator>(basic_string_view<CharT, Traits> x,
                           basic_string_view<CharT, Traits> y) noexcept; // (1) C++17
}

概要

basic_string_viewオブジェクトにおいて、左辺が右辺より大きいかの判定を行う。

戻り値

return x.compare(y) > 0;

#include <iostream>
#include <string_view>

int main()
{
  std::string_view a = "aaa";
  std::string_view b = "bbb";

  if (b > a) {
    std::cout << "greater" << std::endl;
  }
  else {
    std::cout << "less equal" << std::endl;
  }
}

出力例

greater

バージョン

言語

  • C++17

処理系

参照