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

履歴 編集

function
<typeindex>

std::type_index::operator>=(C++11)

bool operator>=(const type_index& rhs) const noexcept;

概要

左辺が右辺以上かの判定を行う。

戻り値

!target->before(*rhs.target)

targetは、type_indexのメンバ変数として保持されているtype_infoオブジェクトへのポインタ(説明用)

例外

投げない

#include <iostream>
#include <typeindex>
#include <set>
#include <string>
#include <algorithm>
#include <functional>

std::string get_typename(const std::type_index& t)
{
  if (t == typeid(int))    return "int";
  if (t == typeid(double)) return "double";
  if (t == typeid(char))   return "char";
  return "bad type!!!";
}

int main()
{
  std::set<std::type_index, std::greater_equal<std::type_index>> s;

  s.insert(typeid(int));
  s.insert(typeid(double));
  s.insert(typeid(char));

  std::for_each(s.begin(), s.end(), [](const std::type_index& t) {
    std::cout << get_typename(t) << std::endl;
  });
}

出力例

int
double
char

バージョン

言語

  • C++11

処理系