[cfe-dev] Function accepting rvalue and lvalue references
Michael Lehn
michael.lehn at uni-ulm.de
Tue Oct 2 17:03:23 PDT 2012
Assume I have some templated class
template <typename T>
struct Dummy {
// ...
};
and that I want to overload a fucntion 'foo' such that it accepts a lvalue or
rvalue reference of it. I can do this using some 'IsDummy trait' as follows:
template <typename A>
std::enable_if<IsDummy<A>::value, void>
foo(A &&dummy)
{
// ....
}
So this is not the problem. However, I somehow think that for some time a function
like
template <typename A>
void
foo(Dummy<A> &&dummy)
{
// ....
}
was capturing both, lvalue and rvalue reference. Does my memory trick me? Was it
a compiler bug (I am not sure whether I was using gcc or clang)?
Cheers,
Michael
More information about the cfe-dev
mailing list