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
処理系
- Clang: ??
- GCC: 16 (
-freflectionオプション指定) ✅ - Visual C++: ??