how to use enable_if for parameters?

Hi,
I want to have two definitions for createRawVector and one is to exist only when the parameter is an rvalue reference. I can test for T but how can I test for the parameter x?
I am assuming that the createRawVector(...) will only be called if the other overload is not available.

Any ideas?

Thanks,
Juan

struct X {

template<typename T>
std::enable_if_t<std::is_rvalue_reference<decltype(x)>::value>
createRawVector(T&& x)
{
T* p2 = new T {};
}

void createRawVector(...) {

}
template<typename T>
void pointer_mod(T&& x)
{
if ( std::is_lvalue_reference<decltype(x)>::value )
{
cout << "is Lvalue reference\n";
}
if ( std::is_rvalue_reference<decltype(x)>::value) {
cout << "is Rvalue reference\n";
}
createRawVector(x);
}
};

Have you tried std::enable_if_t<std::is_rvalue_reference<T&&>::value>?
Thanks, it worked!!!
Topic archived. No new replies allowed.