I can’t seem to find a good solution for using SFINAE with variadic template classes.
Let’s say I have a variadic template object which doesn’t like references:
template<typename... Args>
class NoRef
{
//if any of Args... is a reference, this class will break
//for example:
std::tuple<std::unique_ptr<Args>...> uptrs;
};
And a class which conveniently checks if an argument pack contains references:
template<typename T, typename... Other>
struct RefCheck
{
static const bool value = std::is_reference<T>::value || RefCheck<Other...>::value;
};
template<typename T>
struct RefCheck<T>
{
static const bool value = std::is_reference<T>::value;
};
How do I use this to specialize NoRef for the case where references are present in the arg pack?
This doesn’t use SFINAE, but essentially does what you intend: