1 #ifndef BOOST_METAPARSE_V1_IMPL_STRING_ITERATOR_HPP
2 #define BOOST_METAPARSE_V1_IMPL_STRING_ITERATOR_HPP
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/metaparse/v1/impl/string_iterator_tag.hpp>
10 #include <boost/metaparse/v1/impl/at_c.hpp>
13 #include <boost/mpl/iterator_tags.hpp>
14 #include <boost/mpl/int.hpp>
15 #include <boost/mpl/bool.hpp>
17 #include <boost/type_traits/is_same.hpp>
28 template <class S, int N>
29 struct string_iterator
31 typedef string_iterator type;
32 typedef string_iterator_tag tag;
33 typedef boost::mpl::random_access_iterator_tag category;
38 template <class S, int N>
41 template <class S, int N, int P>
42 struct advance_c<string_iterator<S, N>, P> :
43 string_iterator<S, N + P>
48 template <class A, class B>
51 template <class S, int A, int B>
52 struct distance<string_iterator<S, A>, string_iterator<S, B> > :
53 boost::mpl::int_<B - A>
69 struct advance_impl<boost::metaparse::v1::impl::string_iterator_tag>
71 typedef advance_impl type;
73 template <class S, class N>
75 boost::metaparse::v1::impl::advance_c<
76 typename S::type, N::type::value
86 struct distance_impl<boost::metaparse::v1::impl::string_iterator_tag>
88 typedef distance_impl type;
90 template <class A, class B>
92 boost::metaparse::v1::impl::distance<
103 template <class S, int N>
104 struct next<boost::metaparse::v1::impl::string_iterator<S, N> > :
105 boost::metaparse::v1::impl::string_iterator<S, N + 1>
112 template <class S, int N>
113 struct prior<boost::metaparse::v1::impl::string_iterator<S, N> > :
114 boost::metaparse::v1::impl::string_iterator<S, N - 1>
121 template <class S, int N>
122 struct deref<boost::metaparse::v1::impl::string_iterator<S, N> > :
123 boost::metaparse::v1::impl::at_c<S, N>
127 template <class A, class B>
128 struct equal_to_impl;
131 struct equal_to_impl<
132 boost::metaparse::v1::impl::string_iterator_tag,
133 boost::metaparse::v1::impl::string_iterator_tag
136 typedef equal_to_impl type;
138 template <class A, class B>
139 struct apply : is_same<typename A::type, typename B::type> {};
143 struct equal_to_impl<boost::metaparse::v1::impl::string_iterator_tag, T>
145 typedef equal_to_impl type;
147 template <class, class>
148 struct apply : false_ {};
152 struct equal_to_impl<T, boost::metaparse::v1::impl::string_iterator_tag> :
153 equal_to_impl<boost::metaparse::v1::impl::string_iterator_tag, T>