What is the "universal" to check a pointer is std::unique_ptr
, which works with const &
and custom deleters. Maybe is there any way to check all smart pointers at once?
I want to
- write some function to check empty variant, if it contains only pointers (i.e raw,
std::unique_ptr
,std::shared_ptr
) and - check instantiation of it by
std::enable_if
But what I should write in condition?
template <typename... T>
std::enable_if_t<???, bool>
IsEmptyVariantOfPointers(const std::variant<T...>& variant)
{
bool emptyVariant = true;
std::visit([&emptyVariant](auto&& arg)
{
emptyVariant = arg == nullptr;
}, variant);
return emptyVariant;
}
NOTE: I'm interested the option without template function overloading by pointer types.