Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/fusion/iterator/distance.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
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_DISTANCE_09172005_0721) | |
8 #define FUSION_DISTANCE_09172005_0721 | |
9 | |
10 #include <boost/fusion/iterator/detail/distance.hpp> | |
11 #include <boost/fusion/support/category_of.hpp> | |
12 | |
13 #include <boost/mpl/int.hpp> | |
14 #include <boost/mpl/assert.hpp> | |
15 #include <boost/type_traits/is_same.hpp> | |
16 | |
17 #include <boost/fusion/support/tag_of.hpp> | |
18 | |
19 namespace boost { namespace fusion | |
20 { | |
21 struct random_access_traversal_tag; | |
22 | |
23 // Special tags: | |
24 struct iterator_facade_tag; // iterator facade tag | |
25 struct boost_array_iterator_tag; // boost::array iterator tag | |
26 struct mpl_iterator_tag; // mpl sequence iterator tag | |
27 struct std_pair_iterator_tag; // std::pair iterator tag | |
28 | |
29 namespace extension | |
30 { | |
31 template <typename Tag> | |
32 struct distance_impl | |
33 { | |
34 // default implementation | |
35 template <typename First, typename Last> | |
36 struct apply : distance_detail::linear_distance<First, Last> | |
37 {}; | |
38 }; | |
39 | |
40 template <> | |
41 struct distance_impl<iterator_facade_tag> | |
42 { | |
43 template <typename First, typename Last> | |
44 struct apply : First::template distance<First, Last> {}; | |
45 }; | |
46 | |
47 template <> | |
48 struct distance_impl<boost_array_iterator_tag>; | |
49 | |
50 template <> | |
51 struct distance_impl<mpl_iterator_tag>; | |
52 | |
53 template <> | |
54 struct distance_impl<std_pair_iterator_tag>; | |
55 } | |
56 | |
57 namespace result_of | |
58 { | |
59 template <typename First, typename Last> | |
60 struct distance | |
61 : extension::distance_impl<typename detail::tag_of<First>::type>:: | |
62 template apply<First, Last> | |
63 { | |
64 typedef typename extension::distance_impl<typename detail::tag_of<First>::type>:: | |
65 template apply<First, Last>::type distance_application; | |
66 BOOST_STATIC_CONSTANT(int, value = distance_application::value); | |
67 }; | |
68 } | |
69 | |
70 template <typename First, typename Last> | |
71 inline typename result_of::distance<First, Last>::type | |
72 distance(First const& a, Last const& b) | |
73 { | |
74 return result_of::distance<First, Last>::call(a,b); | |
75 } | |
76 }} | |
77 | |
78 #endif |