|
Boost : |
From: Andres Llopis (allopis_at_[hidden])
Date: 2019-12-06 08:55:57
Hi everyone,
I am trying to make my own version of combine so that it works also with std::tuples. Someone on slack suggested that the zip iterator should be able to handle it properly. My attempt however fails when trying to use the metafunction tuple_of_references::type for the std::tuple of iterators. This is what I tried (https://godbolt.org/z/Ymjtvn):
(Please excuse any style problems, this is my first post)
namespace myns
{
using boost::iterators::zip_iterator;
using boost::iterator_range;
template<typename IterTuple>
class combined_range
: public iterator_range<zip_iterator<IterTuple> >
{
typedef iterator_range<zip_iterator<IterTuple> > base;
public:
combined_range(IterTuple first, IterTuple last)
: base(first, last)
{
}
};
template<typename... Ranges>
auto combine(Ranges&&... rngs) ->
combined_range<decltype(std::make_tuple(std::begin(rngs)...))>
{
return combined_range<decltype(std::make_tuple(std::begin(rngs)...))>(
std::make_tuple(std::begin(rngs)...),
std::make_tuple(std::end(rngs)...));
}
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk