Boost Range Joined Range

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> > Thank you! -- Ali Nakipoglu

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

Thank you ver much Nate. Very good idea! Best, Ali Sent from my iPad On Oct 1, 2012, at 11:45 PM, Nathan Ridge <zeratul976@hotmail.com> wrote:
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 (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
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
Ali Nakipoglu
-
Ali Nakipoğlu
-
Nathan Ridge