I need a type trait to check whether all types in a parameter pack are copy constructible. This is what I\'ve done so far. The main function contains some test cases, to che
If the inheritance from std::true_type
or std::false_type
is not important, then this can be done in straightforward way without SFINAE:
template
struct areCopyConstructible;
template<>
struct areCopyConstructible<> : std::true_type {};
template
struct areCopyConstructible {
static constexpr bool value = std::is_copy_constructible::value
&& areCopyConstructible::value;
};
If you want to inherit from std::true_type
or std::false_type
, you can use std::conditional
:
template
struct areCopyConstructible;
template<>
struct areCopyConstructible<> : std::true_type {};
template
struct areCopyConstructible :
std::conditional::value,
areCopyConstructible,
std::false_type
>::type
{};