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

履歴 編集

function
<meta>

std::meta::is_nothrow_assignable_type(C++26)

namespace std::meta {
  consteval bool is_nothrow_assignable_type(info type_dst, info type_src);
}

概要

例外を送出せずに代入可能かを判定する。std::is_nothrow_assignableに対応する。

戻り値

type_dsttype_srcが表す型について、例外を送出せずに代入可能な場合にtrueを返す。

例外

type_dstまたはtype_srcが型を表さない場合、std::meta::exception例外を送出する。

#include <meta>

struct A {};
struct B {
  B& operator=(const A&) noexcept { return *this; }
};
struct C {
  C& operator=(const A&) noexcept(false) { return *this; }
};

int main() {
  static_assert(std::meta::is_nothrow_assignable_type(^^int&, ^^int));
  // B::operator=(const A&)はnoexcept
  static_assert(std::meta::is_nothrow_assignable_type(^^B&, ^^const A&));
  // C::operator=(const A&)はnoexcept(false)
  static_assert(!std::meta::is_nothrow_assignable_type(^^C&, ^^const A&));
}

出力

バージョン

言語

  • C++26

処理系

参照