]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Joel de Guzman | |
3 | ||
4 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ==============================================================================*/ | |
7 | #if !defined(FUSION_CONVERT_ITERATOR_05062005_1218) | |
8 | #define FUSION_CONVERT_ITERATOR_05062005_1218 | |
9 | ||
10 | #include <boost/fusion/support/config.hpp> | |
11 | #include <boost/fusion/support/is_iterator.hpp> | |
12 | #include <boost/mpl/if.hpp> | |
13 | #include <boost/mpl/bool.hpp> | |
14 | ||
15 | namespace boost { namespace fusion | |
16 | { | |
17 | template <typename Iterator> | |
18 | struct mpl_iterator; // forward declaration | |
19 | ||
20 | // Test T. If it is a fusion iterator, return a reference to it. | |
21 | // else, assume it is an mpl iterator. | |
22 | ||
23 | template <typename T> | |
24 | struct convert_iterator | |
25 | { | |
26 | typedef typename | |
27 | mpl::if_< | |
28 | is_fusion_iterator<T> | |
29 | , T | |
30 | , mpl_iterator<T> | |
31 | >::type | |
32 | type; | |
33 | ||
34 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
35 | static T const& | |
36 | call(T const& x, mpl::true_) | |
37 | { | |
38 | return x; | |
39 | } | |
40 | ||
41 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
42 | static mpl_iterator<T> | |
43 | call(T const& /*x*/, mpl::false_) | |
44 | { | |
45 | return mpl_iterator<T>(); | |
46 | } | |
47 | ||
48 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
49 | static typename | |
50 | mpl::if_< | |
51 | is_fusion_iterator<T> | |
52 | , T const& | |
53 | , mpl_iterator<T> | |
54 | >::type | |
55 | call(T const& x) | |
56 | { | |
57 | return call(x, is_fusion_iterator<T>()); | |
58 | } | |
59 | }; | |
60 | }} | |
61 | ||
62 | #endif |