Chris@16: /*============================================================================= Chris@16: Copyright (c) 2005-2013 Joel de Guzman Chris@16: Copyright (c) 2005-2006 Dan Marsden Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: ==============================================================================*/ Chris@16: #if !defined(BOOST_FUSION_MAP_ITERATOR_02042013_0835) Chris@16: #define BOOST_FUSION_MAP_ITERATOR_02042013_0835 Chris@16: Chris@101: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@16: Chris@16: namespace boost { namespace fusion Chris@16: { Chris@16: struct random_access_traversal_tag; Chris@16: Chris@16: template Chris@16: struct map_iterator Chris@16: : iterator_facade< Chris@16: map_iterator Chris@16: , typename Seq::category> Chris@16: { Chris@16: typedef Seq sequence; Chris@16: typedef mpl::int_ index; Chris@16: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: map_iterator(Seq& seq) Chris@16: : seq_(seq) Chris@16: {} Chris@16: Chris@16: template Chris@16: struct value_of Chris@16: { Chris@16: typedef typename Iterator::sequence sequence; Chris@16: typedef typename Iterator::index index; Chris@16: typedef Chris@101: decltype(boost::declval().get_val(index())) Chris@16: type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct value_of_data Chris@16: { Chris@16: typedef typename Iterator::sequence sequence; Chris@16: typedef typename Iterator::index index; Chris@16: typedef Chris@101: decltype(boost::declval().get_val(index()).second) Chris@16: type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct key_of Chris@16: { Chris@16: typedef typename Iterator::sequence sequence; Chris@16: typedef typename Iterator::index index; Chris@101: typedef decltype(boost::declval().get_key(index())) key_identity_type; Chris@101: typedef typename key_identity_type::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct deref Chris@16: { Chris@16: typedef typename Iterator::sequence sequence; Chris@16: typedef typename Iterator::index index; Chris@16: typedef Chris@101: decltype(boost::declval().get(index())) Chris@16: type; Chris@16: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: static type Chris@16: call(Iterator const& it) Chris@16: { Chris@16: return it.seq_.get(typename Iterator::index()); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct deref_data Chris@16: { Chris@16: typedef typename Iterator::sequence sequence; Chris@16: typedef typename Iterator::index index; Chris@16: Chris@101: typedef decltype(boost::declval().get(index()).second) second_type_; Chris@101: Chris@101: typedef typename Chris@101: mpl::if_< Chris@101: is_const Chris@101: , typename add_const::type Chris@101: , second_type_ Chris@101: >::type Chris@101: second_type; Chris@101: Chris@101: typedef typename add_reference::type type; Chris@101: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: static type Chris@16: call(Iterator const& it) Chris@16: { Chris@16: return it.seq_.get(typename Iterator::index()).second; Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct advance Chris@16: { Chris@16: typedef typename Iterator::index index; Chris@16: typedef typename Iterator::sequence sequence; Chris@16: typedef map_iterator type; Chris@16: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: static type Chris@16: call(Iterator const& i) Chris@16: { Chris@16: return type(i.seq_); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct next Chris@16: : advance > Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct prior Chris@16: : advance > Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct distance Chris@16: { Chris@16: typedef typename Chris@16: mpl::minus< Chris@16: typename I2::index, typename I1::index Chris@16: >::type Chris@16: type; Chris@16: Chris@101: BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED Chris@16: static type Chris@16: call(I1 const&, I2 const&) Chris@16: { Chris@16: return type(); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct equal_to Chris@16: : mpl::equal_to Chris@16: {}; Chris@16: Chris@16: Seq& seq_; Chris@16: Chris@16: private: Chris@16: // silence MSVC warning C4512: assignment operator could not be generated Chris@16: map_iterator& operator= (map_iterator const&); Chris@16: }; Chris@16: Chris@16: }} Chris@16: Chris@101: #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 Chris@101: namespace std Chris@101: { Chris@101: template Chris@101: struct iterator_traits< ::boost::fusion::map_iterator > Chris@101: { }; Chris@101: } Chris@16: #endif Chris@101: Chris@101: #endif