Files
boost_mpl/include/boost/mpl/distance.hpp
T

79 lines
2.0 KiB
C++
Raw Normal View History

2002-09-15 22:13:24 +00:00
#ifndef BOOST_MPL_DISTANCE_HPP_INCLUDED
#define BOOST_MPL_DISTANCE_HPP_INCLUDED
2004-09-02 15:41:37 +00:00
// 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.
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
// $Source$
// $Date$
// $Revision$
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
#include <boost/mpl/distance_fwd.hpp>
#include <boost/mpl/iter_fold.hpp>
#include <boost/mpl/iterator_range.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/tag.hpp>
#include <boost/mpl/apply_wrap.hpp>
#include <boost/mpl/aux_/msvc_eti_base.hpp>
#include <boost/mpl/aux_/value_wknd.hpp>
#include <boost/mpl/aux_/na_spec.hpp>
#include <boost/mpl/aux_/config/forwarding.hpp>
#include <boost/mpl/aux_/config/static_constant.hpp>
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
namespace boost { namespace mpl {
2002-09-15 22:13:24 +00:00
2004-09-02 15:41:37 +00:00
// default implementation for forward/bidirectional iterators
template< typename Tag > struct distance_impl
2002-09-15 22:13:24 +00:00
{
2004-09-02 15:41:37 +00:00
template< typename First, typename Last > struct apply
#if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
: aux::msvc_eti_base< typename iter_fold<
2002-09-15 22:13:24 +00:00
iterator_range<First,Last>
2004-09-02 15:41:37 +00:00
, long_<0>
2002-09-15 22:13:24 +00:00
, next<>
2004-09-02 15:41:37 +00:00
>::type >
2002-09-15 22:13:24 +00:00
{
2004-09-02 15:41:37 +00:00
#else
{
typedef typename iter_fold<
iterator_range<First,Last>
, long_<0>
, next<>
>::type type;
BOOST_STATIC_CONSTANT(long, value =
(iter_fold<
iterator_range<First,Last>
, long_<0>
, next<>
>::type::value)
);
#endif
2002-09-15 22:13:24 +00:00
};
};
template<
2004-09-02 15:41:37 +00:00
typename BOOST_MPL_AUX_NA_PARAM(First)
, typename BOOST_MPL_AUX_NA_PARAM(Last)
2002-09-15 22:13:24 +00:00
>
struct distance
2004-09-02 15:41:37 +00:00
: distance_impl< typename tag<First>::type >
::template apply<First, Last>
2002-09-15 22:13:24 +00:00
{
2004-09-02 15:41:37 +00:00
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, distance, (First, Last))
2002-09-15 22:13:24 +00:00
};
2004-09-02 15:41:37 +00:00
BOOST_MPL_AUX_NA_SPEC(2, distance)
2003-03-11 11:59:49 +00:00
2004-09-02 15:41:37 +00:00
}}
2002-09-15 22:13:24 +00:00
#endif // BOOST_MPL_DISTANCE_HPP_INCLUDED