]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/iterator/mpl/convert_iterator.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / iterator / mpl / convert_iterator.hpp
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/is_iterator.hpp>
11 #include <boost/mpl/if.hpp>
12 #include <boost/mpl/bool.hpp>
13
14 namespace boost { namespace fusion
15 {
16     template <typename Iterator>
17     struct mpl_iterator; // forward declaration
18
19     //  Test T. If it is a fusion iterator, return a reference to it.
20     //  else, assume it is an mpl iterator.
21
22     template <typename T>
23     struct convert_iterator
24     {
25         typedef typename
26             mpl::if_<
27                 is_fusion_iterator<T>
28               , T
29               , mpl_iterator<T>
30             >::type
31         type;
32
33         static T const&
34         call(T const& x, mpl::true_)
35         {
36             return x;
37         }
38
39         static mpl_iterator<T>
40         call(T const& /*x*/, mpl::false_)
41         {
42             return mpl_iterator<T>();
43         }
44
45         static typename
46             mpl::if_<
47                 is_fusion_iterator<T>
48               , T const&
49               , mpl_iterator<T>
50             >::type
51         call(T const& x)
52         {
53             return call(x, is_fusion_iterator<T>());
54         }
55     };
56 }}
57
58 #endif