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

履歴 編集

function template
<meta>

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

namespace std::meta {
  template <reflection_range R = std::initializer_list<info>>
  consteval bool is_nothrow_constructible_type(info type, R&& type_args);
}

概要

例外を送出せずに構築可能かを判定する。std::is_nothrow_constructibleに対応する。

戻り値

typeが表す型がtype_argsで指定された引数型で例外を送出せずに構築可能な場合にtrueを返す。

例外

typeまたはtype_argsの各要素が型を表さない場合、std::meta::exception例外を送出する。

#include <meta>

struct Safe {
  Safe(int, double) noexcept {}
};

struct Throwing {
  Throwing(int, double) noexcept(false) {}
};

int main() {
  static_assert(std::meta::is_nothrow_constructible_type(^^int, {^^int}));
  static_assert(std::meta::is_nothrow_constructible_type(^^Safe, {^^int, ^^double}));
  static_assert(!std::meta::is_nothrow_constructible_type(^^Throwing, {^^int, ^^double}));
}

出力

バージョン

言語

  • C++26

処理系

参照