X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Ffusion%2Fiterator%2Fdetail%2Fsegmented_iterator.hpp;fp=boost%2Ffusion%2Fiterator%2Fdetail%2Fsegmented_iterator.hpp;h=a5cfb450cd073fca64b0450e7e87c548bbb42ee5;hp=0000000000000000000000000000000000000000;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/fusion/iterator/detail/segmented_iterator.hpp b/boost/fusion/iterator/detail/segmented_iterator.hpp new file mode 100644 index 0000000..a5cfb45 --- /dev/null +++ b/boost/fusion/iterator/detail/segmented_iterator.hpp @@ -0,0 +1,144 @@ +/*============================================================================= + Copyright (c) 2011 Eric Niebler + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_FUSION_SEGMENTED_ITERATOR_SEGMENTED_ITERATOR_HPP_INCLUDED) +#define BOOST_FUSION_SEGMENTED_ITERATOR_SEGMENTED_ITERATOR_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct nil_; + + namespace detail + { + template + struct segmented_next_impl; + } + + // A segmented iterator wraps a "context", which is a cons list + // of ranges, the frontmost is range over values and the rest + // are ranges over internal segments. + template + struct segmented_iterator + : iterator_facade, forward_traversal_tag> + { + explicit segmented_iterator(Context const& ctx) + : context(ctx) + {} + + //auto deref(it) + //{ + // return deref(begin(car(it.context))) + //} + template + struct deref + { + typedef + typename result_of::deref< + typename It::context_type::car_type::begin_type + >::type + type; + + static type call(It const& it) + { + return *it.context.car.first; + } + }; + + //auto deref_data(it) + //{ + // return deref_data(begin(car(it.context))) + //} + template + struct deref_data + { + typedef + typename result_of::deref_data< + typename It::context_type::car_type::begin_type + >::type + type; + + static type call(It const& it) + { + return fusion::deref_data(it.context.car.first); + } + }; + + //auto key_of(it) + //{ + // return key_of(begin(car(it.context))) + //} + template + struct key_of + : result_of::key_of + {}; + + //auto value_of(it) + //{ + // return value_of(begin(car(it.context))) + //} + template + struct value_of + : result_of::value_of + {}; + + //auto value_of_data(it) + //{ + // return value_of_data(begin(car(it.context))) + //} + template + struct value_of_data + : result_of::value_of_data + {}; + + // Compare all the segment iterators in each stack, starting with + // the bottom-most. + template < + typename It1 + , typename It2 + , int Size1 = It1::context_type::size::value + , int Size2 = It2::context_type::size::value + > + struct equal_to + : mpl::false_ + {}; + + template + struct equal_to + : detail::segmented_equal_to< + typename It1::context_type + , typename It2::context_type + > + {}; + + template + struct next + { + typedef detail::segmented_next_impl impl; + typedef segmented_iterator type; + + static type call(It const& it) + { + return type(impl::call(it.context)); + } + }; + + typedef Context context_type; + context_type context; + }; + +}} + +#endif