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

履歴 編集

function
<text_encoding>

std::text_encoding::operator==(C++26)

friend constexpr bool operator==(const text_encoding& a,
                                 const text_encoding& b) noexcept; // (1) C++26
friend constexpr bool operator==(const text_encoding& encoding,
                                 id i) noexcept;                   // (2) C++26

概要

text_encodingオブジェクト同士、またはtext_encodingオブジェクトとid列挙値の等値比較を行う。

  • (1) : 2つのtext_encodingオブジェクトが同じエンコーディングを表すかを判定する
  • (2) : text_encodingオブジェクトが指定したMIB値に対応するエンコーディングかを判定する

戻り値

  • (1) : a.mib_ == id::other && b.mib_ == id::othertrueの場合、comp-name(a.name_, b.name_)を返す。そうでなければa.mib_ == b.mib_を返す
  • (2) : encoding.mib_ == iを返す

備考

  • (1) : IANA登録済みエンコーディングはMIB値で比較される。未登録エンコーディング(id::other)は名前で比較される
  • (2) : i != id::otherの場合に限り、引数に対する同値関係を導く。id::otherとの比較は同値関係にならない(a == id::other && b == id::otherであってもa == bとは限らない)

#include <text_encoding>
#include <cassert>

int main() {
  // MIBによる比較
  std::text_encoding utf8_a{"utf-8"};
  std::text_encoding utf8_b{"UTF8"};
  assert(utf8_a == utf8_b); // 同じMIBを持つ

  // id列挙値との比較
  assert(utf8_a == std::text_encoding::id::UTF8);

  // 未登録エンコーディングは名前で比較
  std::text_encoding wtf8_a{"WTF-8"};
  std::text_encoding wtf8_b{"wtf8"};
  assert(wtf8_a == wtf8_b); // comp-nameで比較

  // 異なる未登録エンコーディング
  std::text_encoding other_a{"WTF-8"};
  std::text_encoding other_b{"Some-Other"};
  assert(other_a != other_b);
}

出力

バージョン

言語

  • C++26

処理系

参照