std::meta::is_copy_constructible_type, std::meta::is_trivially_copy_constructible_type, std::meta::is_nothrow_copy_constructible_type
| Defined in header <meta>
|
||
consteval bool is_copy_constructible_type( std::meta::info r );
|
(1) | (since C++26) |
consteval bool is_trivially_copy_constructible_type( std::meta::info r );
|
(2) | (since C++26) |
consteval bool is_nothrow_copy_constructible_type( std::meta::info r );
|
(3) | (since C++26) |
Returns true if r represents a type T that is
copy constructible,
trivially copy constructible or
non-throwing copy constructible, respectively.
return std::is_copy_constructible_v<T>;.return std::is_trivially_copy_constructible_v<T>;.return std::is_nothrow_copy_constructible_v<T>;.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.
Parameters
| r | - | a reflection value |
Return value
true if r represents a type that is:
as described above. Otherwise, false.
Exceptions
Throws std::meta::exception if r does not represent a type or type alias.
Notes
is_copy_constructible_type may report true for (reflected) types that have a copy constructor, but are ill-formed to invoke, such as ^^std::vector<std::mutex>.
Example
#include <meta>
#include <string>
struct S1
{
std::string str; // member has a non-trivial copy constructor
};
static_assert(is_copy_constructible_type(^^S1));
static_assert(!is_trivially_copy_constructible_type(^^S1));
struct S2
{
int n;
S2(const S2&) = default; // trivial and non-throwing
};
static_assert(is_trivially_copy_constructible_type(^^S2));
static_assert(is_nothrow_copy_constructible_type(^^S2));
struct S3
{
S3(const S3&) = delete; // explicitly deleted
};
static_assert(!is_copy_constructible_type(^^S3));
struct S4
{
S4(S4&) {}; // cannot bind const, hence not a copy-constructible
};
static_assert(!is_copy_constructible_type(^^S4));
int main() {}
