• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2006 Dan Marsden
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_FUSION_DEREF_IMPL_20060222_1952)
9 #define BOOST_FUSION_DEREF_IMPL_20060222_1952
10 
11 #include <boost/static_assert.hpp>
12 #include <boost/type_traits/is_const.hpp>
13 #include <boost/mpl/if.hpp>
14 
15 #include <string>
16 
17 namespace example
18 {
19     struct example_struct_iterator_tag;
20 
21     template<typename Struct, int Pos>
22     struct example_struct_iterator;
23 }
24 
25 namespace boost { namespace fusion {
26 
27     namespace extension
28     {
29         template<typename Tag>
30         struct deref_impl;
31 
32         template<>
33         struct deref_impl<example::example_struct_iterator_tag>
34         {
35             template<typename Iterator>
36             struct apply;
37 
38             template<typename Struct>
39             struct apply<example::example_struct_iterator<Struct, 0> >
40             {
41                 typedef typename mpl::if_<
42                     is_const<Struct>, std::string const&, std::string&>::type type;
43 
44                 static type
callboost::fusion::extension::deref_impl::apply45                 call(example::example_struct_iterator<Struct, 0> const& it)
46                 {
47                     return it.struct_.name;
48                 }
49             };
50 
51             template<typename Struct>
52             struct apply<example::example_struct_iterator<Struct, 1> >
53             {
54                 typedef typename mpl::if_<
55                     is_const<Struct>, int const&, int&>::type type;
56 
57                 static type
callboost::fusion::extension::deref_impl::apply58                 call(example::example_struct_iterator<Struct, 1> const& it)
59                 {
60                     return it.struct_.age;
61                 }
62             };
63         };
64     }
65 }}
66 
67 #endif
68