os/ossrv/ossrv_pub/boost_apis/boost/detail/iterator.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// (C) Copyright David Abrahams 2002.
sl@0
     2
// Distributed under the Boost Software License, Version 1.0. (See
sl@0
     3
// accompanying file LICENSE_1_0.txt or copy at
sl@0
     4
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
     5
sl@0
     6
// Boost versions of
sl@0
     7
//
sl@0
     8
//    std::iterator_traits<>::iterator_category
sl@0
     9
//    std::iterator_traits<>::difference_type
sl@0
    10
//    std::distance()
sl@0
    11
//
sl@0
    12
// ...for all compilers and iterators
sl@0
    13
//
sl@0
    14
// Additionally, if X is a pointer
sl@0
    15
//    std::iterator_traits<X>::pointer
sl@0
    16
sl@0
    17
// Otherwise, if partial specialization is supported or X is not a pointer
sl@0
    18
//    std::iterator_traits<X>::value_type
sl@0
    19
//    std::iterator_traits<X>::pointer
sl@0
    20
//    std::iterator_traits<X>::reference
sl@0
    21
//
sl@0
    22
// See http://www.boost.org for most recent version including documentation.
sl@0
    23
sl@0
    24
// Revision History
sl@0
    25
// 04 Mar 2001 - More attempted fixes for Intel C++ (David Abrahams)
sl@0
    26
// 03 Mar 2001 - Put all implementation into namespace
sl@0
    27
//               boost::detail::iterator_traits_. Some progress made on fixes
sl@0
    28
//               for Intel compiler. (David Abrahams)
sl@0
    29
// 02 Mar 2001 - Changed BOOST_MSVC to BOOST_MSVC_STD_ITERATOR in a few
sl@0
    30
//               places. (Jeremy Siek)
sl@0
    31
// 19 Feb 2001 - Improved workarounds for stock MSVC6; use yes_type and
sl@0
    32
//               no_type from type_traits.hpp; stopped trying to remove_cv
sl@0
    33
//               before detecting is_pointer, in honor of the new type_traits
sl@0
    34
//               semantics. (David Abrahams)
sl@0
    35
// 13 Feb 2001 - Make it work with nearly all standard-conforming iterators
sl@0
    36
//               under raw VC6. The one category remaining which will fail is
sl@0
    37
//               that of iterators derived from std::iterator but not
sl@0
    38
//               boost::iterator and which redefine difference_type.
sl@0
    39
// 11 Feb 2001 - Clean away code which can never be used (David Abrahams)
sl@0
    40
// 09 Feb 2001 - Always have a definition for each traits member, even if it
sl@0
    41
//               can't be properly deduced. These will be incomplete types in
sl@0
    42
//               some cases (undefined<void>), but it helps suppress MSVC errors
sl@0
    43
//               elsewhere (David Abrahams)
sl@0
    44
// 07 Feb 2001 - Support for more of the traits members where possible, making
sl@0
    45
//               this useful as a replacement for std::iterator_traits<T> when
sl@0
    46
//               used as a default template parameter.
sl@0
    47
// 06 Feb 2001 - Removed useless #includes of standard library headers
sl@0
    48
//               (David Abrahams)
sl@0
    49
sl@0
    50
#ifndef ITERATOR_DWA122600_HPP_
sl@0
    51
# define ITERATOR_DWA122600_HPP_
sl@0
    52
sl@0
    53
# include <boost/config.hpp>
sl@0
    54
# include <iterator>
sl@0
    55
sl@0
    56
// STLPort 4.0 and betas have a bug when debugging is enabled and there is no
sl@0
    57
// partial specialization: instead of an iterator_category typedef, the standard
sl@0
    58
// container iterators have _Iterator_category.
sl@0
    59
//
sl@0
    60
// Also, whether debugging is enabled or not, there is a broken specialization
sl@0
    61
// of std::iterator<output_iterator_tag,void,void,void,void> which has no
sl@0
    62
// typedefs but iterator_category.
sl@0
    63
# if defined(__SGI_STL_PORT)
sl@0
    64
sl@0
    65
#  if (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && defined(__STL_DEBUG)
sl@0
    66
#   define BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
sl@0
    67
#  endif
sl@0
    68
sl@0
    69
#  define BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
sl@0
    70
sl@0
    71
# endif // STLPort <= 4.1b4 && no partial specialization
sl@0
    72
sl@0
    73
# if !defined(BOOST_NO_STD_ITERATOR_TRAITS)             \
sl@0
    74
  && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
sl@0
    75
  && !defined(BOOST_MSVC_STD_ITERATOR)
sl@0
    76
    
sl@0
    77
namespace boost { namespace detail {
sl@0
    78
sl@0
    79
// Define a new template so it can be specialized
sl@0
    80
template <class Iterator>
sl@0
    81
struct iterator_traits
sl@0
    82
    : std::iterator_traits<Iterator>
sl@0
    83
{};
sl@0
    84
using std::distance;
sl@0
    85
sl@0
    86
}} // namespace boost::detail
sl@0
    87
sl@0
    88
# else
sl@0
    89
sl@0
    90
#  if  !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)  \
sl@0
    91
    && !defined(BOOST_MSVC_STD_ITERATOR)
sl@0
    92
sl@0
    93
// This is the case where everything conforms except BOOST_NO_STD_ITERATOR_TRAITS
sl@0
    94
sl@0
    95
namespace boost { namespace detail {
sl@0
    96
sl@0
    97
// Rogue Wave Standard Library fools itself into thinking partial
sl@0
    98
// specialization is missing on some platforms (e.g. Sun), so fails to
sl@0
    99
// supply iterator_traits!
sl@0
   100
template <class Iterator>
sl@0
   101
struct iterator_traits
sl@0
   102
{
sl@0
   103
    typedef typename Iterator::value_type value_type;
sl@0
   104
    typedef typename Iterator::reference reference;
sl@0
   105
    typedef typename Iterator::pointer pointer;
sl@0
   106
    typedef typename Iterator::difference_type difference_type;
sl@0
   107
    typedef typename Iterator::iterator_category iterator_category;
sl@0
   108
};
sl@0
   109
sl@0
   110
template <class T>
sl@0
   111
struct iterator_traits<T*>
sl@0
   112
{
sl@0
   113
    typedef T value_type;
sl@0
   114
    typedef T& reference;
sl@0
   115
    typedef T* pointer;
sl@0
   116
    typedef std::ptrdiff_t difference_type;
sl@0
   117
    typedef std::random_access_iterator_tag iterator_category;
sl@0
   118
};
sl@0
   119
sl@0
   120
template <class T>
sl@0
   121
struct iterator_traits<T const*>
sl@0
   122
{
sl@0
   123
    typedef T value_type;
sl@0
   124
    typedef T const& reference;
sl@0
   125
    typedef T const* pointer;
sl@0
   126
    typedef std::ptrdiff_t difference_type;
sl@0
   127
    typedef std::random_access_iterator_tag iterator_category;
sl@0
   128
};
sl@0
   129
sl@0
   130
}} // namespace boost::detail
sl@0
   131
sl@0
   132
#  else
sl@0
   133
sl@0
   134
# include <boost/type_traits/remove_const.hpp>
sl@0
   135
# include <boost/type_traits/detail/yes_no_type.hpp>
sl@0
   136
# include <boost/type_traits/is_pointer.hpp>
sl@0
   137
sl@0
   138
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
sl@0
   139
#  include <boost/type_traits/is_same.hpp>
sl@0
   140
#  include <boost/type_traits/remove_pointer.hpp>
sl@0
   141
# endif
sl@0
   142
# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
sl@0
   143
#  include <boost/type_traits/is_base_and_derived.hpp>
sl@0
   144
# endif
sl@0
   145
sl@0
   146
# include <boost/mpl/if.hpp>
sl@0
   147
# include <boost/mpl/has_xxx.hpp>
sl@0
   148
# include <cstddef>
sl@0
   149
sl@0
   150
// should be the last #include
sl@0
   151
# include "boost/type_traits/detail/bool_trait_def.hpp"
sl@0
   152
sl@0
   153
namespace boost { namespace detail {
sl@0
   154
sl@0
   155
BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
sl@0
   156
BOOST_MPL_HAS_XXX_TRAIT_DEF(reference)
sl@0
   157
BOOST_MPL_HAS_XXX_TRAIT_DEF(pointer)
sl@0
   158
BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type)
sl@0
   159
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category)
sl@0
   160
sl@0
   161
// is_mutable_iterator --
sl@0
   162
//
sl@0
   163
//   A metafunction returning true iff T is a mutable iterator type
sl@0
   164
//   with a nested value_type. Will only work portably with iterators
sl@0
   165
//   whose operator* returns a reference, but that seems to be OK for
sl@0
   166
//   the iterators supplied by Dinkumware. Some input iterators may
sl@0
   167
//   compile-time if they arrive here, and if the compiler is strict
sl@0
   168
//   about not taking the address of an rvalue.
sl@0
   169
sl@0
   170
// This one detects ordinary mutable iterators - the result of
sl@0
   171
// operator* is convertible to the value_type.
sl@0
   172
template <class T>
sl@0
   173
type_traits::yes_type is_mutable_iterator_helper(T const*, BOOST_DEDUCED_TYPENAME T::value_type*);
sl@0
   174
sl@0
   175
// Since you can't take the address of an rvalue, the guts of
sl@0
   176
// is_mutable_iterator_impl will fail if we use &*t directly.  This
sl@0
   177
// makes sure we can still work with non-lvalue iterators.
sl@0
   178
template <class T> T* mutable_iterator_lvalue_helper(T& x);
sl@0
   179
int mutable_iterator_lvalue_helper(...);
sl@0
   180
sl@0
   181
sl@0
   182
// This one detects output iterators such as ostream_iterator which
sl@0
   183
// return references to themselves.
sl@0
   184
template <class T>
sl@0
   185
type_traits::yes_type is_mutable_iterator_helper(T const*, T const*);
sl@0
   186
sl@0
   187
type_traits::no_type is_mutable_iterator_helper(...);
sl@0
   188
sl@0
   189
template <class T>
sl@0
   190
struct is_mutable_iterator_impl
sl@0
   191
{
sl@0
   192
    static T t;
sl@0
   193
    
sl@0
   194
    BOOST_STATIC_CONSTANT(
sl@0
   195
        bool, value = sizeof(
sl@0
   196
            detail::is_mutable_iterator_helper(
sl@0
   197
                (T*)0
sl@0
   198
              , mutable_iterator_lvalue_helper(*t) // like &*t
sl@0
   199
            ))
sl@0
   200
        == sizeof(type_traits::yes_type)
sl@0
   201
    );
sl@0
   202
};
sl@0
   203
sl@0
   204
BOOST_TT_AUX_BOOL_TRAIT_DEF1(
sl@0
   205
    is_mutable_iterator,T,::boost::detail::is_mutable_iterator_impl<T>::value)
sl@0
   206
sl@0
   207
sl@0
   208
// is_full_iterator_traits --
sl@0
   209
//
sl@0
   210
//   A metafunction returning true iff T has all the requisite nested
sl@0
   211
//   types to satisfy the requirements for a fully-conforming
sl@0
   212
//   iterator_traits implementation.
sl@0
   213
template <class T>
sl@0
   214
struct is_full_iterator_traits_impl
sl@0
   215
{
sl@0
   216
    enum { value = 
sl@0
   217
           has_value_type<T>::value 
sl@0
   218
           & has_reference<T>::value 
sl@0
   219
           & has_pointer<T>::value 
sl@0
   220
           & has_difference_type<T>::value
sl@0
   221
           & has_iterator_category<T>::value
sl@0
   222
    };
sl@0
   223
};
sl@0
   224
sl@0
   225
BOOST_TT_AUX_BOOL_TRAIT_DEF1(
sl@0
   226
    is_full_iterator_traits,T,::boost::detail::is_full_iterator_traits_impl<T>::value)
sl@0
   227
sl@0
   228
sl@0
   229
#   ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
sl@0
   230
BOOST_MPL_HAS_XXX_TRAIT_DEF(_Iterator_category)
sl@0
   231
    
sl@0
   232
// is_stlport_40_debug_iterator --
sl@0
   233
//
sl@0
   234
//   A metafunction returning true iff T has all the requisite nested
sl@0
   235
//   types to satisfy the requirements of an STLPort 4.0 debug iterator
sl@0
   236
//   iterator_traits implementation.
sl@0
   237
template <class T>
sl@0
   238
struct is_stlport_40_debug_iterator_impl
sl@0
   239
{
sl@0
   240
    enum { value = 
sl@0
   241
           has_value_type<T>::value 
sl@0
   242
           & has_reference<T>::value 
sl@0
   243
           & has_pointer<T>::value 
sl@0
   244
           & has_difference_type<T>::value
sl@0
   245
           & has__Iterator_category<T>::value
sl@0
   246
    };
sl@0
   247
};
sl@0
   248
sl@0
   249
BOOST_TT_AUX_BOOL_TRAIT_DEF1(
sl@0
   250
    is_stlport_40_debug_iterator,T,::boost::detail::is_stlport_40_debug_iterator_impl<T>::value)
sl@0
   251
sl@0
   252
template <class T>
sl@0
   253
struct stlport_40_debug_iterator_traits
sl@0
   254
{
sl@0
   255
    typedef typename T::value_type value_type;
sl@0
   256
    typedef typename T::reference reference;
sl@0
   257
    typedef typename T::pointer pointer;
sl@0
   258
    typedef typename T::difference_type difference_type;
sl@0
   259
    typedef typename T::_Iterator_category iterator_category;
sl@0
   260
};
sl@0
   261
#   endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF 
sl@0
   262
sl@0
   263
template <class T> struct pointer_iterator_traits;
sl@0
   264
sl@0
   265
#   ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
sl@0
   266
template <class T>
sl@0
   267
struct pointer_iterator_traits<T*>
sl@0
   268
{
sl@0
   269
    typedef typename remove_const<T>::type value_type;
sl@0
   270
    typedef T* pointer;
sl@0
   271
    typedef T& reference;
sl@0
   272
    typedef std::random_access_iterator_tag iterator_category;
sl@0
   273
    typedef std::ptrdiff_t difference_type;
sl@0
   274
};
sl@0
   275
#   else
sl@0
   276
sl@0
   277
// In case of no template partial specialization, and if T is a
sl@0
   278
// pointer, iterator_traits<T>::value_type can still be computed.  For
sl@0
   279
// some basic types, remove_pointer is manually defined in
sl@0
   280
// type_traits/broken_compiler_spec.hpp. For others, do it yourself.
sl@0
   281
sl@0
   282
template<class P> class please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee;
sl@0
   283
sl@0
   284
template<class P>
sl@0
   285
struct pointer_value_type
sl@0
   286
  : mpl::if_<
sl@0
   287
        is_same<P, typename remove_pointer<P>::type>
sl@0
   288
      , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee<P>
sl@0
   289
      , typename remove_const<
sl@0
   290
            typename remove_pointer<P>::type
sl@0
   291
        >::type
sl@0
   292
    >
sl@0
   293
{
sl@0
   294
};
sl@0
   295
sl@0
   296
sl@0
   297
template<class P>
sl@0
   298
struct pointer_reference
sl@0
   299
  : mpl::if_<
sl@0
   300
        is_same<P, typename remove_pointer<P>::type>
sl@0
   301
      , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee<P>
sl@0
   302
      , typename remove_pointer<P>::type&
sl@0
   303
    >
sl@0
   304
{
sl@0
   305
};
sl@0
   306
sl@0
   307
template <class T>
sl@0
   308
struct pointer_iterator_traits
sl@0
   309
{
sl@0
   310
    typedef T pointer;
sl@0
   311
    typedef std::random_access_iterator_tag iterator_category;
sl@0
   312
    typedef std::ptrdiff_t difference_type;
sl@0
   313
sl@0
   314
    typedef typename pointer_value_type<T>::type value_type;
sl@0
   315
    typedef typename pointer_reference<T>::type reference;
sl@0
   316
};
sl@0
   317
sl@0
   318
#   endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
sl@0
   319
sl@0
   320
// We'll sort iterator types into one of these classifications, from which we
sl@0
   321
// can determine the difference_type, pointer, reference, and value_type
sl@0
   322
template <class Iterator>
sl@0
   323
struct standard_iterator_traits
sl@0
   324
{
sl@0
   325
    typedef typename Iterator::difference_type difference_type;
sl@0
   326
    typedef typename Iterator::value_type value_type;
sl@0
   327
    typedef typename Iterator::pointer pointer;
sl@0
   328
    typedef typename Iterator::reference reference;
sl@0
   329
    typedef typename Iterator::iterator_category iterator_category;
sl@0
   330
};
sl@0
   331
sl@0
   332
template <class Iterator>
sl@0
   333
struct msvc_stdlib_mutable_traits
sl@0
   334
    : std::iterator_traits<Iterator>
sl@0
   335
{
sl@0
   336
    typedef typename std::iterator_traits<Iterator>::distance_type difference_type;
sl@0
   337
    typedef typename std::iterator_traits<Iterator>::value_type* pointer;
sl@0
   338
    typedef typename std::iterator_traits<Iterator>::value_type& reference;
sl@0
   339
};
sl@0
   340
sl@0
   341
template <class Iterator>
sl@0
   342
struct msvc_stdlib_const_traits
sl@0
   343
    : std::iterator_traits<Iterator>
sl@0
   344
{
sl@0
   345
    typedef typename std::iterator_traits<Iterator>::distance_type difference_type;
sl@0
   346
    typedef const typename std::iterator_traits<Iterator>::value_type* pointer;
sl@0
   347
    typedef const typename std::iterator_traits<Iterator>::value_type& reference;
sl@0
   348
};
sl@0
   349
sl@0
   350
#   ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
sl@0
   351
template <class Iterator>
sl@0
   352
struct is_bad_output_iterator
sl@0
   353
    : is_base_and_derived<
sl@0
   354
        std::iterator<std::output_iterator_tag,void,void,void,void>
sl@0
   355
        , Iterator>
sl@0
   356
{
sl@0
   357
};
sl@0
   358
sl@0
   359
struct bad_output_iterator_traits
sl@0
   360
{
sl@0
   361
    typedef void value_type;
sl@0
   362
    typedef void difference_type;
sl@0
   363
    typedef std::output_iterator_tag iterator_category;
sl@0
   364
    typedef void pointer;
sl@0
   365
    typedef void reference;
sl@0
   366
};
sl@0
   367
#   endif
sl@0
   368
sl@0
   369
// If we're looking at an MSVC6 (old Dinkumware) ``standard''
sl@0
   370
// iterator, this will generate an appropriate traits class. 
sl@0
   371
template <class Iterator>
sl@0
   372
struct msvc_stdlib_iterator_traits
sl@0
   373
    : mpl::if_<
sl@0
   374
       is_mutable_iterator<Iterator>
sl@0
   375
       , msvc_stdlib_mutable_traits<Iterator>
sl@0
   376
       , msvc_stdlib_const_traits<Iterator>
sl@0
   377
      >::type
sl@0
   378
{};
sl@0
   379
sl@0
   380
template <class Iterator>
sl@0
   381
struct non_pointer_iterator_traits
sl@0
   382
    : mpl::if_<
sl@0
   383
        // if the iterator contains all the right nested types...
sl@0
   384
        is_full_iterator_traits<Iterator>
sl@0
   385
        // Use a standard iterator_traits implementation
sl@0
   386
        , standard_iterator_traits<Iterator>
sl@0
   387
#   ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
sl@0
   388
        // Check for STLPort 4.0 broken _Iterator_category type
sl@0
   389
        , mpl::if_<
sl@0
   390
             is_stlport_40_debug_iterator<Iterator>
sl@0
   391
             , stlport_40_debug_iterator_traits<Iterator>
sl@0
   392
#   endif
sl@0
   393
        // Otherwise, assume it's a Dinkum iterator
sl@0
   394
        , msvc_stdlib_iterator_traits<Iterator>
sl@0
   395
#   ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
sl@0
   396
        >::type
sl@0
   397
#   endif 
sl@0
   398
    >::type
sl@0
   399
{
sl@0
   400
};
sl@0
   401
sl@0
   402
template <class Iterator>
sl@0
   403
struct iterator_traits_aux
sl@0
   404
    : mpl::if_<
sl@0
   405
        is_pointer<Iterator>
sl@0
   406
        , pointer_iterator_traits<Iterator>
sl@0
   407
        , non_pointer_iterator_traits<Iterator>
sl@0
   408
    >::type
sl@0
   409
{
sl@0
   410
};
sl@0
   411
sl@0
   412
template <class Iterator>
sl@0
   413
struct iterator_traits
sl@0
   414
{
sl@0
   415
    // Explicit forwarding from base class needed to keep MSVC6 happy
sl@0
   416
    // under some circumstances.
sl@0
   417
 private:
sl@0
   418
#   ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
sl@0
   419
    typedef 
sl@0
   420
    typename mpl::if_<
sl@0
   421
        is_bad_output_iterator<Iterator>
sl@0
   422
        , bad_output_iterator_traits
sl@0
   423
        , iterator_traits_aux<Iterator>
sl@0
   424
    >::type base;
sl@0
   425
#   else
sl@0
   426
    typedef iterator_traits_aux<Iterator> base;
sl@0
   427
#   endif
sl@0
   428
 public:
sl@0
   429
    typedef typename base::value_type value_type;
sl@0
   430
    typedef typename base::pointer pointer;
sl@0
   431
    typedef typename base::reference reference;
sl@0
   432
    typedef typename base::difference_type difference_type;
sl@0
   433
    typedef typename base::iterator_category iterator_category;
sl@0
   434
};
sl@0
   435
sl@0
   436
// This specialization cuts off ETI (Early Template Instantiation) for MSVC.
sl@0
   437
template <> struct iterator_traits<int>
sl@0
   438
{
sl@0
   439
    typedef int value_type;
sl@0
   440
    typedef int pointer;
sl@0
   441
    typedef int reference;
sl@0
   442
    typedef int difference_type;
sl@0
   443
    typedef int iterator_category;
sl@0
   444
};
sl@0
   445
sl@0
   446
}} // namespace boost::detail
sl@0
   447
sl@0
   448
#  endif // workarounds
sl@0
   449
sl@0
   450
namespace boost { namespace detail {
sl@0
   451
sl@0
   452
namespace iterator_traits_
sl@0
   453
{
sl@0
   454
  template <class Iterator, class Difference>
sl@0
   455
  struct distance_select
sl@0
   456
  {
sl@0
   457
      static Difference execute(Iterator i1, const Iterator i2, ...)
sl@0
   458
      {
sl@0
   459
          Difference result = 0;
sl@0
   460
          while (i1 != i2)
sl@0
   461
          {
sl@0
   462
              ++i1;
sl@0
   463
              ++result;
sl@0
   464
          }
sl@0
   465
          return result;
sl@0
   466
      }
sl@0
   467
sl@0
   468
      static Difference execute(Iterator i1, const Iterator i2, std::random_access_iterator_tag*)
sl@0
   469
      {
sl@0
   470
          return i2 - i1;
sl@0
   471
      }
sl@0
   472
  };
sl@0
   473
} // namespace boost::detail::iterator_traits_
sl@0
   474
sl@0
   475
template <class Iterator>
sl@0
   476
inline typename iterator_traits<Iterator>::difference_type
sl@0
   477
distance(Iterator first, Iterator last)
sl@0
   478
{
sl@0
   479
    typedef typename iterator_traits<Iterator>::difference_type diff_t;
sl@0
   480
    typedef typename ::boost::detail::iterator_traits<Iterator>::iterator_category iterator_category;
sl@0
   481
    
sl@0
   482
    return iterator_traits_::distance_select<Iterator,diff_t>::execute(
sl@0
   483
        first, last, (iterator_category*)0);
sl@0
   484
}
sl@0
   485
sl@0
   486
}}
sl@0
   487
sl@0
   488
# endif
sl@0
   489
sl@0
   490
sl@0
   491
# undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
sl@0
   492
# undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
sl@0
   493
sl@0
   494
#endif // ITERATOR_DWA122600_HPP_