|
Boost : |
Subject: Re: [boost] [range] adaptors vs. rvalue to lvalue& binding
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-03-22 11:02:56
Arno Schödl wrote:
> ideally I would like to use range-adapted lvalue ranges like any other
> lvalue ranges. Writing it down naively, as below, does not compile because
> LoadRefRange takes (and should take?) the range it modifies by lvalue&,
> while adaptor expressions are rvalues.
>
> template<typename Range>
> void modifies_range( Range& rng );
>
<snip>
>
> Any thoughts?
You can use something like this:
template <typename Range>
typename boost::enable_if<
// Check whether
// `typename range_reference<typename remove_reference<Range>::type>::type`
// is non-const reference
>::type
modify_range(Range&& rng)
{
/*
*/
}
Regards,
Michel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk