|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef ZIPPED_RANGE_H
|
|
Toshihiro Shimizu |
890ddd |
#define ZIPPED_RANGE_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// boost includes
|
|
Toshihiro Shimizu |
890ddd |
#include <boost range.hpp=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
#include <boost iterator="" zip_iterator.hpp=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\file zipped_range.h
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\brief Contains a range creator for boost::zip_iterator objects.
|
|
Toshihiro Shimizu |
890ddd |
\remark Zipped ranges are currently constrained to a 2-tuple.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename rng1,="" rng2="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct _zip_rng_traits {
|
|
Toshihiro Shimizu |
890ddd |
typedef boost::zip_iterator
|
|
Toshihiro Shimizu |
890ddd |
typename boost::range_iterator<rng1>::type,</rng1>
|
|
Toshihiro Shimizu |
890ddd |
typename boost::range_iterator<rng2>::type>> iterator;</rng2>
|
|
Toshihiro Shimizu |
890ddd |
typedef std::pair<iterator, iterator=""> range;</iterator,>
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Permuted Range creator
|
|
Toshihiro Shimizu |
890ddd |
//**********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename rng1,="" rng2="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
typename _zip_rng_traits<rng1, rng2="">::range</rng1,>
|
|
Toshihiro Shimizu |
890ddd |
zipped_range(Rng1 &rng1, Rng2 &rng2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
typedef typename _zip_rng_traits<rng1, rng2="">::range range;</rng1,>
|
|
Toshihiro Shimizu |
890ddd |
typedef typename _zip_rng_traits<rng1, rng2="">::iterator iterator;</rng1,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return range(iterator(boost::make_tuple(boost::begin(rng1), boost::begin(rng2))),
|
|
Toshihiro Shimizu |
890ddd |
iterator(boost::make_tuple(boost::end(rng1), boost::end(rng2))));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // ZIPPED_RANGE_H
|