std::meta::is_constructible_type, std::meta::is_trivially_constructible_type, std::meta::is_nothrow_constructible_type
| Defined in header <meta>
|
||
template< std::meta::reflection_range Args = std::initializer_list<std::meta::info> >
consteval bool is_constructible_type( std::meta::info r, Args&& args );
|
(1) | (since C++26) |
template< std::meta::reflection_range Args = std::initializer_list<std::meta::info> >
consteval bool is_trivially_constructible_type( std::meta::info r, Args&& args );
|
(2) | (since C++26) |
template< std::meta::reflection_range Args = std::initializer_list<std::meta::info> >
consteval bool is_nothrow_constructible_type( std::meta::info r, Args&& args );
|
(3) | (since C++26) |
Returns true if r represents a type T that is
constructible,
trivially constructible or
non-throwing constructible, respectively, from the range args of reflected types or type aliases.
Let ARGS... be a pack of types or type aliases whose elements are represented by the corresponding elements of args.
return std::is_constructible_v<T, ARGS...>;.return std::is_trivially_constructible_v<T, ARGS...>;.return std::is_nothrow_constructible_v<T, ARGS...>;.If T is not a complete type, (possibly cv-qualified) void, or an array of unknown bound, the program is ill-formed.
If an instantiation of a template above depends, directly or indirectly, on an incomplete type, and that instantiation could yield a different result if that type were hypothetically completed, the program is ill-formed.
Template parameters
| Args | - | range type that contains reflected types |
Parameters
| r | - | a reflection value to test |
| args | - | a range of reflected argument types |
Return value
true if r represents a type that is:
from args as described above. Otherwise, false.
Exceptions
Throws std::meta::exception:
- If either
ror any element ofargsdoes not represent a type or type alias. - If
Tor any type in the packARGS...is not a complete type, (possibly cv-qualified)void, or an array of unknown bound. - If an instantiation of a template (1-3) depends, directly or indirectly, on an incomplete type, and that instantiation could yield a different result if that type were hypothetically completed.
Example
#include <meta>
class C
{
int v1;
double v2;
public:
C(int n) : v1(n), v2() {}
C(int n, double f) noexcept : v1(n), v2(f) {}
};
static_assert
(""
&& is_trivially_constructible_type(^^C, {^^const C&})
&& ! is_trivially_constructible_type(^^C, {^^int})
&& is_constructible_type(^^C, {^^int})
&& ! is_nothrow_constructible_type(^^C, {^^int})
&& is_nothrow_constructible_type(^^C, {^^int, ^^double})
);
int main() {}
See also
(C++26) |
checks if reflected type is a non-union class type (function) |
(C++26)(C++26)(C++26)(C++26) |
checks if the reflected entity is a constructor of this kind (function) |
| checks if reflected type has a default constructor (function) | |
| checks if reflected type has a copy constructor (function) | |
| checks if reflected type can be constructed from an rvalue reference (function) | |
(C++20) |
specifies that a variable of the type can be constructed from or bound to a set of argument types (concept) |
(C++11)(C++11)(C++11) |
checks if a type has a constructor for specific arguments (class template) |