namespace std {
template <class T, std::size_t N>
constexpr bool operator==(const inplace_vector<T, N>& x,
const inplace_vector<T, N>& y); // (1) C++26
}
概要
inplace_vectorオブジェクトの等値比較を行う。
要件
型Tが==で比較可能であること。
戻り値
xとyの要素数および要素の値が等しければtrue、そうでなければfalseを返す。
計算量
線形時間。ただし、xとyのサイズが異なる場合は定数時間。
備考
- この演算子により、以下の演算子が使用可能になる:
operator!=
例
#include <print>
#include <inplace_vector>
int main()
{
std::inplace_vector<int, 5> v1 = {1, 2, 3};
std::inplace_vector<int, 5> v2 = {1, 2, 3};
std::inplace_vector<int, 5> v3 = {1, 2, 4};
// operator==
std::println("{}", (v1 == v2));
std::println("{}", (v1 == v3));
// operator==から自動導出されるoperator!=
std::println("{}", (v1 != v2));
std::println("{}", (v1 != v3));
}
出力
true
false
false
true
バージョン
言語
- C++26
処理系
- Clang: 23 ✅
- GCC: 16 ✅
- Visual C++: 2026 Update 2 ❌