Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-05-30 13:48:47


Thorsten Ottosen wrote:
> Eric Niebler wrote:
>> Neal Becker wrote:
>>
>>> #include <boost/range.hpp>
>>> #include <vector>
>>>
>>> template<typename in_t, typename out_t>
>>> void copy (in_t const& in, out_t &out) {}
>>>
>>> int main() {
>>> std::vector<int> out (2);
>>> copy (boost::make_iterator_range (out.begin(), out.begin()+2),
>>> boost::make_iterator_range (out.begin(), out.begin()+2));
>>> }
>>
>>
>> If make_iterator_range() returned a const-qualified iterator_range<>,
>> this would work. Thorsten?
>
> Isn't the problem thet out is a reference?

out is a reference, which means that non-const rvalues will not bind to
it. But const rvalues will because out_t will be deduced to be
"iterator_range<> const". Try it and see.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk