[range] range metafunctions and reference types
Hello,
The range metafunctions currently do not work on range reference types.
For example, the following:
#include <vector>
#include
Den 30-07-2011 01:13, Nathan Ridge skrev:
But now range_iterator gives an error as indicated above, so we have to do something awkward and verbose like this:
template<typename Range>
typename range_iterator
::type some_function(Range&& r) { ... } Could the range metafunctions be modified to accept range reference parameters and remove the reference themselves?
This is indeed annoying. I guess we could do the following for all
meta-functions:
template< class T >
struct meta
template<typename Range>
typename range_iterator
::type some_function(Range&& r) { ... } Could the range metafunctions be modified to accept range reference parameters and remove the reference themselves?
allthough we should probably be careful here; maybe its better just to say template< class R > auto some_fun( R&& r ) -> decltype(boost::begin(r)); -Thorsten
template<typename Range>
typename range_iterator
::type some_function(Range&& r) { ... } Could the range metafunctions be modified to accept range reference parameters and remove the reference themselves?
allthough we should probably be careful here; maybe its better just to say
template< class R > auto some_fun( R&& r ) -> decltype(boost::begin(r));
What do we need to be careful about? IMO this is a case where writing out the return type (range_iterator<R>::type) is more readable than using decltype. Regards, Nate
participants (2)
-
Nathan Ridge
-
Thorsten Ottosen