#include <type_traits>
struct A
{};
struct B
{
B(A
) {};
};
struct C
{
explicit C(A
) {}
};
static_assert(std
::is_constructible_v
<B
, A
>);
static_assert(std
::is_convertible_v
<A
, B
>);
static_assert(std
::is_constructible_v
<C
, A
>);
static_assert(! std
::is_convertible_v
<A
, C
>);
std::is_convertible要求转换必须是隐式的,std::is_constructible隐式显式都可以
转载请注明原文地址:https://ipadbbs.8miu.com/read-52264.html