Boost logo

Boost :

Subject: Re: [boost] Boost Range Joined Range
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-10-01 16:45:39


> How can i create copy a joined_range type and it contents? Any alternatives
> to make this?
>
> For example
>
> typedef std::vector<int> VectorT;
> typedef joined_range< VectorT, VectorT> JoinedRangeT;
>
> VectorT vector0, vector1;
>
> JoinedRangeT joinedRange0( vector0, vector1 )
>
> // I need this
> JoinedRangeT joinedRange1 = copyAnyRangeOrContainer( joinedRange0 );
>
> Im planning to use your advices to design copyAnyRangeOrContainer function,
> so that it can create deep copies from given range or containers that are
> can be vector,map, joined_range<T1,T2> or even
> joined_range<joined_range<T1,T2>, joined_range<T1, T2> >

Is it important that the return type of copyAnyRangeOrContainer be the
same type as its argument? It seems to me that, since you're deep copying
the elements anyways, you might as well have it return a specific range type
(e.g. std::vector) for all input types, in which case it can be implemented
like so:

template <typename RangeT>
std::vector<typename range_value<RangeT>::value>
copyAnyRangeOrContainer(const RangeT& input)
{
    std::vector<typename range_value<RangeT>::value> result;
    push_back(result, input);
    return result;
}

Regards,
Nate
                                               


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