KASKADE 7 development version
fixfusion.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2002-2011 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#if !defined(FIXFUSION_H)
14#define FIXFUSION_H
15
16#include <boost/mpl/range_c.hpp>
17
18#include <boost/fusion/algorithm.hpp>
19#include <boost/fusion/sequence.hpp>
20
21template <class Seq1, class Seq2>
22boost::fusion::zip_view<boost::fusion::vector<Seq1&,Seq2&> > zip2(Seq1& s1, Seq2& s2)
23{
24 return boost::fusion::zip_view< boost::fusion::vector<Seq1&,Seq2&> >(boost::fusion::vector<Seq1&,Seq2&>(s1,s2));
25}
26
27template <class Seq1, class Seq2, class Func>
28void for_each2(Seq1 const& s1, Seq2& s2, Func const& func)
29{
30 using namespace boost::fusion;
31 zip_view<vector<Seq1 const&,Seq2&> > zipped(vector<Seq1 const&,Seq2&>(s1,s2));
32 for_each(zipped,func);
33}
34
38template <int first, int last, class Functor>
39void for_range(Functor& f) {
40 boost::fusion::for_each(typename boost::mpl::range_c<int,first,last>::type(),f);
41}
42
46template <class First, class Last>
47boost::fusion::iterator_range<First,Last> make_iterator_range(First first, Last last)
48{
49 return boost::fusion::iterator_range<First,Last>(first,last);
50}
51
52namespace boost {
53 namespace fusion {
54 namespace result_of {
55
56
60 template <int First, int Last, class Sequence>
62 {
63 typedef iterator_range<typename advance_c<typename begin<Sequence>::type,First>::type,
64 typename advance_c<typename begin<Sequence>::type,Last>::type> type;
65 };
66
67
68 } // End of namespace result_of
69 } // End of namespace fusion
70} // End of namespace Kaskade
71
75template <int First, int Last, class Sequence>
77make_range(Sequence& s)
78{
79 using namespace boost::fusion;
80
81 return make_iterator_range(advance_c<First>(begin(s)),advance_c<Last>(begin(s)));
82}
83
84
85#endif
void for_each2(Seq1 const &s1, Seq2 &s2, Func const &func)
Definition: fixfusion.hh:28
boost::fusion::zip_view< boost::fusion::vector< Seq1 &, Seq2 & > > zip2(Seq1 &s1, Seq2 &s2)
Definition: fixfusion.hh:22
boost::fusion::result_of::make_range< First, Last, Sequence >::type make_range(Sequence &s)
Constructs a boost::fusion view that picks a certain range from a forward sequence.
Definition: fixfusion.hh:77
boost::fusion::iterator_range< First, Last > make_iterator_range(First first, Last last)
Constructs an iterator range from two static boost::fusion iterators.
Definition: fixfusion.hh:47
void for_range(Functor &f)
A half-open integer-range based for-loop.
Definition: fixfusion.hh:39
A meta-function defining a boost::fusion iterator range from given sequence indices.
Definition: fixfusion.hh:62
iterator_range< typename advance_c< typename begin< Sequence >::type, First >::type, typename advance_c< typename begin< Sequence >::type, Last >::type > type
Definition: fixfusion.hh:64