1
//-----------------------------------------------------------------------------
2
// boost mpl/for_each.hpp header file
3
// See http://www.boost.org for updates, documentation, and revision history.
4
//-----------------------------------------------------------------------------
6
// Copyright (c) 2000-02
9
// Permission to use, copy, modify, distribute and sell this software
10
// and its documentation for any purpose is hereby granted without fee,
11
// provided that the above copyright notice appears in all copies and
12
// that both the copyright notice and this permission notice appear in
13
// supporting documentation. No representations are made about the
14
// suitability of this software for any purpose. It is provided "as is"
15
// without express or implied warranty.
17
#ifndef BOOST_MPL_FOR_EACH_HPP_INCLUDED
18
#define BOOST_MPL_FOR_EACH_HPP_INCLUDED
20
#include "boost/mpl/begin_end.hpp"
21
#include "boost/mpl/apply.hpp"
22
#include "boost/mpl/bool.hpp"
23
#include "boost/mpl/lambda.hpp"
24
#include "boost/mpl/identity.hpp"
25
#include "boost/mpl/aux_/unwrap.hpp"
27
#include "boost/type_traits/is_same.hpp"
28
#include "boost/utility/value_init.hpp"
35
template <bool done = true>
40
, typename LastIterator
41
, typename TransformFunc
55
struct for_each_impl<false>
59
, typename LastIterator
60
, typename TransformFunc
70
typedef typename Iterator::type item;
71
typedef typename apply1<TransformFunc,item>::type arg;
73
// dwa 2002/9/10 -- make sure not to invoke undefined behavior
75
value_initialized<arg> x;
76
aux::unwrap(f, 0)(boost::get(x));
78
typedef typename Iterator::next iter;
79
for_each_impl<boost::is_same<iter,LastIterator>::value>::execute(
80
(iter*)0, (LastIterator*)0, (TransformFunc*)0, f);
86
// agurt, 17/mar/02: pointer default parameters are necessary to workaround
87
// MSVC 6.5 function template signature's mangling bug
90
, typename TransformOp
94
void for_each(F f, Sequence* = 0, TransformOp* = 0)
96
typedef typename begin<Sequence>::type first;
97
typedef typename end<Sequence>::type last;
98
typedef typename lambda<TransformOp>::type transform_op;
100
aux::for_each_impl< boost::is_same<first,last>::value >::execute(
101
(first*)0, (last*)0, (transform_op*)0, f);
109
void for_each(F f, Sequence* = 0)
111
for_each<Sequence, identity<> >(f);
117
#endif // BOOST_MPL_FOR_EACH_HPP_INCLUDED