fix doc example typo
[boost.git] / boost / fusion / iterator / deref.hpp
blob0e6f54d299aa7949c56ef45624101171e7acb5fd
1 /*=============================================================================
2 Copyright (c) 2001-2006 Joel de Guzman
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_DEREF_05042005_1019)
8 #define FUSION_DEREF_05042005_1019
10 #include <boost/fusion/support/iterator_base.hpp>
11 #include <boost/fusion/support/tag_of.hpp>
13 namespace boost { namespace fusion
15 // Special tags:
16 struct iterator_facade_tag; // iterator facade tag
17 struct array_iterator_tag; // boost::array iterator tag
18 struct mpl_iterator_tag; // mpl sequence iterator tag
19 struct std_pair_iterator_tag; // std::pair iterator tag
21 namespace extension
23 template <typename Tag>
24 struct deref_impl
26 template <typename Iterator>
27 struct apply {};
30 template <>
31 struct deref_impl<iterator_facade_tag>
33 template <typename Iterator>
34 struct apply : Iterator::template deref<Iterator> {};
37 template <>
38 struct deref_impl<array_iterator_tag>;
40 template <>
41 struct deref_impl<mpl_iterator_tag>;
43 template <>
44 struct deref_impl<std_pair_iterator_tag>;
47 namespace result_of
49 template <typename Iterator>
50 struct deref
51 : extension::deref_impl<typename detail::tag_of<Iterator>::type>::
52 template apply<Iterator>
53 {};
56 template <typename Iterator>
57 typename result_of::deref<Iterator>::type
58 deref(Iterator const& i)
60 typedef result_of::deref<Iterator> deref_meta;
61 return deref_meta::call(i);
64 template <typename Iterator>
65 typename result_of::deref<Iterator>::type
66 operator*(iterator_base<Iterator> const& i)
68 return fusion::deref(i.cast());
72 #endif