I have the following (well known) table:
Can I test it by using type_traits
?
I wrote:
class CSpecialMethods
{
public:
// CSpecialMethods() {}
// CSpecialMethods(bool) {}
// CSpecialMethods(const CSpecialMethods& rhs) {}
CSpecialMethods& operator=(const CSpecialMethods& rhs) {} // declare user copy assignment operator, nothing else
// CSpecialMethods(CSpecialMethods&& rhs) {}
// CSpecialMethods& operator=(CSpecialMethods&& rhs) {}
// ~CSpecialMethods() {}
};
and
std::clog << "constructors:" << std::endl;
std::clog << std::is_trivially_default_constructible_v<CSpecialMethods> << std::endl;
std::clog << std::is_trivially_constructible_v<CSpecialMethods> << std::endl;
std::clog << "copy methods:" << std::endl;
std::clog << std::is_trivially_copy_constructible_v<CSpecialMethods> << std::endl;
std::clog << std::is_trivially_copy_assignable_v<CSpecialMethods> << std::endl;
std::clog << "move methods:" << std::endl;
std::clog << std::is_trivially_move_constructible_v<CSpecialMethods> << std::endl;
std::clog << std::is_trivially_move_assignable_v<CSpecialMethods> << std::endl;
std::clog << "destructor:" << std::endl;
std::clog << std::is_trivially_destructible_v<CSpecialMethods> << std::endl;
but the outcome does not reflect the table:
constructors:
1
1
copy methods:
1
0
move methods:
1
0
destructor:
1
So, can I reproduce that special members table using type_traits
?
If I write:
class CSpecialMethods
{
public:
// CSpecialMethods() {}
// CSpecialMethods(bool) {}
CSpecialMethods(const CSpecialMethods& rhs) = default;
CSpecialMethods& operator=(const CSpecialMethods& rhs) {}
// CSpecialMethods(CSpecialMethods&& rhs) {}
// CSpecialMethods& operator=(CSpecialMethods&& rhs) {}
// ~CSpecialMethods() {}
};
I got:
constructors:
0
0
copy methods:
1
0
move methods:
1
0
destructor:
1
Quite different then other sample, but still, doesn't reflect the top table ...