File indexing completed on 2025-01-18 09:34:41
0001
0002
0003
0004
0005
0006
0007 #if !defined(FUSION_DISTANCE_09172005_0721)
0008 #define FUSION_DISTANCE_09172005_0721
0009
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/iterator/detail/distance.hpp>
0012 #include <boost/fusion/support/category_of.hpp>
0013
0014 #include <boost/mpl/int.hpp>
0015 #include <boost/mpl/assert.hpp>
0016 #include <boost/type_traits/is_same.hpp>
0017
0018 #include <boost/fusion/support/tag_of.hpp>
0019
0020 namespace boost { namespace fusion
0021 {
0022 struct random_access_traversal_tag;
0023
0024
0025 struct iterator_facade_tag;
0026 struct boost_array_iterator_tag;
0027 struct mpl_iterator_tag;
0028 struct std_pair_iterator_tag;
0029
0030 namespace extension
0031 {
0032 template <typename Tag>
0033 struct distance_impl
0034 {
0035
0036 template <typename First, typename Last>
0037 struct apply : distance_detail::linear_distance<First, Last>
0038 {};
0039 };
0040
0041 template <>
0042 struct distance_impl<iterator_facade_tag>
0043 {
0044 template <typename First, typename Last>
0045 struct apply : First::template distance<First, Last> {};
0046 };
0047
0048 template <>
0049 struct distance_impl<boost_array_iterator_tag>;
0050
0051 template <>
0052 struct distance_impl<mpl_iterator_tag>;
0053
0054 template <>
0055 struct distance_impl<std_pair_iterator_tag>;
0056 }
0057
0058 namespace result_of
0059 {
0060 template <typename First, typename Last>
0061 struct distance
0062 : extension::distance_impl<typename detail::tag_of<First>::type>::
0063 template apply<First, Last>
0064 {
0065 typedef typename extension::distance_impl<typename detail::tag_of<First>::type>::
0066 template apply<First, Last>::type distance_application;
0067 BOOST_STATIC_CONSTANT(int, value = distance_application::value);
0068 };
0069 }
0070
0071 template <typename First, typename Last>
0072 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0073 inline typename result_of::distance<First, Last>::type
0074 distance(First const& a, Last const& b)
0075 {
0076 return result_of::distance<First, Last>::call(a,b);
0077 }
0078 }}
0079
0080 #endif