Reputation: 10539
#include<iostream>
#include<vector>
struct Empty {};
template <typename V>
void add(V&& element)
{
static_assert( std::is_rvalue_reference<V>::value, "V is not a rvalue reference");
}
int main(int argc, char *argv[])
{
add(Empty());
std::cin.ignore();
return 0;
}
I don't get why static_assert fail here, V
isn't equal to V&&
here ?
Upvotes: 2
Views: 1041
Reputation: 96790
V
is not the rvalue-reference - decltype(element)
is (if element
is an rvalue). V
is simply the general type of element
. Specifically:
typename std::remove_reference<decltype(element)>::type; // V
Upvotes: 2