[cfe-dev] Function accepting rvalue and lvalue references
Sean Silva
silvas at purdue.edu
Tue Oct 2 20:44:49 PDT 2012
This gem [1] is a well written and informative article on this topic.
I highly recommend reading it.
[1]. http://blogs.msdn.com/b/vcblog/archive/2009/02/03/rvalue-references-c-0x-features-in-vc10-part-2.aspx
-- Sean Silva
On Tue, Oct 2, 2012 at 8:03 PM, Michael Lehn <michael.lehn at uni-ulm.de> wrote:
>
> 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
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list