Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::range vs && (rvalue ref)
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2013-01-10 22:37:47


> Passing range by ref (&) is fine, but using (&&) results in and error. Any
> ideas?
>
> [snip]

When you pass by T&&, the deduced type of T will include the reference.
(So e.g. if you have a T&& argument and you pass in an int rvalue, T
will be deduced as 'const int&'. If you pass an int lvalue, T will
be deduced as 'int&'. This is in contrast to a regular reference, like
T&, where if you pass an int lvalue, T will be deduced as just 'int').

Range metafunctions don't accept references to range types as their
input; you must pass the range type itself.

So, you must call remove_reference<> on the deduced type 'T' prior to
passing it to a range metafunction.

I wonder if we should change the range metafunctions to accept
references to range types, and do the reference stripping
themselves?

Regards,
Nate
                                               


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net