#ifndef BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED #define BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2000-2004 // // 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) // // See http://www.boost.org/libs/mpl for documentation. // $Source$ // $Date$ // $Revision$ #include #include #include #include #include #include #include #include #include namespace boost { namespace mpl { namespace aux { template< typename T, int N > struct single_element_iter; // random access support template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, N) > struct single_iter_base { typedef random_access_iterator_tag category; typedef mpl::int_ position; template< typename D > struct BOOST_MPL_AUX_ITERATOR_ADVANCE { typedef plus< mpl::int_,D > n_; typedef single_element_iter< T , BOOST_MPL_AUX_VALUE_WKND(n_)::value > type; }; template< typename U > struct BOOST_MPL_AUX_ITERATOR_DISTANCE { typedef typename minus< typename U::position , mpl::int_ >::type type; }; }; #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template< typename T > struct single_element_iter : single_iter_base { typedef single_element_iter next; typedef T type; }; template< typename T > struct single_element_iter : single_iter_base { typedef single_element_iter prior; }; #else template< BOOST_MPL_AUX_NTTP_DECL(int, N) > struct single_iter_impl { template< typename T > struct result_; }; template<> struct single_iter_impl<0> { template< typename T > struct result_ : single_iter_base { typedef single_element_iter next; typedef T type; }; }; template<> struct single_iter_impl<1> { template< typename T > struct result_ : single_iter_base { typedef single_element_iter prior; }; }; template< typename T, BOOST_MPL_AUX_NTTP_DECL(int, N) > struct single_element_iter : single_iter_impl::template result_ { }; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION } // namespace aux }} #endif // BOOST_MPL_AUX_SINGLE_ELEMENT_ITER_HPP_INCLUDED