
Thorsten Ottosen wrote:
Neal Becker wrote:
Thorsten Ottosen 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) {} What makes you think you can bind a temporary to an non-const reference (out)?
Yeah, same old problem. I think the c+ standard should be changed.
Well, && will help some.
It's quite clear (to me) that this is an important use of the range concept.
I think the algorothm is wrong in this case. I would go for
template< class SinglePassRange, class WritableForwardRange > void overwrite( const SinglePassRange&, WriteForwardRange& );
template< class SinglePassRange, class WritableForwardRange > void overwrite( const SinglePassRange&, const WriteForwardRange& );
If you don't want to write two overloads (or if you want to use a function that returns non-const-qualifed iterator_range). the "official" workaround maybe looks like... int main() { std::vector<int> out (2); copy (boost::make_iterator_range (out.begin(), out.begin()+2), boost::lambda::make_const(boost::make_iterator_range (out.begin(), out.begin()+2)) ); } -- Shunsuke Sogame