zip_view.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef BOOST_MPL_ZIP_VIEW_HPP_INCLUDED
  2. #define BOOST_MPL_ZIP_VIEW_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2000-2010
  4. // Copyright David Abrahams 2000-2002
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/mpl for documentation.
  11. // $Id$
  12. // $Date$
  13. // $Revision$
  14. #include <boost/mpl/transform.hpp>
  15. #include <boost/mpl/begin_end.hpp>
  16. #include <boost/mpl/iterator_tags.hpp>
  17. #include <boost/mpl/next.hpp>
  18. #include <boost/mpl/lambda.hpp>
  19. #include <boost/mpl/deref.hpp>
  20. #include <boost/mpl/aux_/na_spec.hpp>
  21. namespace boost { namespace mpl {
  22. template< typename IteratorSeq >
  23. struct zip_iterator
  24. {
  25. typedef forward_iterator_tag category;
  26. typedef typename transform1<
  27. IteratorSeq
  28. , deref<_1>
  29. >::type type;
  30. typedef zip_iterator<
  31. typename transform1<
  32. IteratorSeq
  33. , mpl::next<_1>
  34. >::type
  35. > next;
  36. };
  37. template<
  38. typename BOOST_MPL_AUX_NA_PARAM(Sequences)
  39. >
  40. struct zip_view
  41. {
  42. private:
  43. typedef typename transform1< Sequences, mpl::begin<_1> >::type first_ones_;
  44. typedef typename transform1< Sequences, mpl::end<_1> >::type last_ones_;
  45. public:
  46. typedef nested_begin_end_tag tag;
  47. typedef zip_view type;
  48. typedef zip_iterator<first_ones_> begin;
  49. typedef zip_iterator<last_ones_> end;
  50. };
  51. BOOST_MPL_AUX_NA_SPEC(1, zip_view)
  52. }}
  53. #endif // BOOST_MPL_ZIP_VIEW_HPP_INCLUDED