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 = {4, 5, 6};
std::array<int, 3> y = {1, 2, 3};
if (x >= y) {
std::cout << "greater equal" << std::endl;
}
else {
std::cout << "less" << std::endl;
}
}
出力
greater equal
バージョン
言語
- C++11
処理系
- Clang: ??
- GCC: 4.7.0 ✅
- ICC: ??
- Visual C++: 2008 (std::tr1) ✅, 2010 ✅, 2012 ✅
参照
- P1023R0
constexpr
comparison operators forstd::array
- P1614R2 The Mothership has Landed
- C++20での三方比較演算子の追加と、関連する演算子の自動導出