United States    
COMPAQ STORE | PRODUCTS | SERVICES | SUPPORT
| CONTACT US | SEARCH
C++
distance_type (3C++std) - Tru64 UNIX
Standard C++ Library
Copyright 1996, Rogue Wave Software, Inc.

NAME

  distance_type  - Determine the type of distance used by an iterator. This
  function is now obsolete.  It is retained in order to provide backward
  compatibility and support compilers that do not provide partial
  specialization.

SYNOPSIS

  #include <iterator>

  template <class T, class Distance>
  inline Distance* distance_type (const input_iterator<T,
       Distance>&)

  template <class T, class Distance>
  inline Distance* distance_type (const forward_iterator<T,
       Distance>&)

  template <class T, class Distance>
  inline Distance*
  distance_type (const bidirectional_iterator<T, Distance>&)

  template <class T, class Distance>
  inline Distance*
  distance_type (const random_access_iterator<T, Distance>&)

  template <class T>
  inline ptrdiff_t* distance_type (const T*)

DESCRIPTION

  The distance_type family of function templates return a pointer to a value
  that is of the same type as that used to represent a distance between two
  iterators.  The first four of these take an iterator of a particular type
  and return a pointer to a default value of the distance_type for that
  iterator.  The T* form of  the function returns ptrdiff_t*.

  Generic algorithms use this function to create local variables of the
  correct type.  The distance_type functions are typically used like this:

  template <class Iterator>
  void foo(Iterator first, Iterator last)
  {
   __foo(begin,end,distance_type(first));
  }

  template <class Iterator, class Distance>
  void __foo(Iterator first, Iterator last, Distance*>
  {
   Distance d = Distance();
   distance(first,last,d);
   _
  }
  The auxiliary function template allows the algorithm to extract a distance
  type from the first iterator and then use that type to perform some useful
  work.

SEE ALSO

  Other iterator primitives:  value_type, iterator_category, distance,
  advance

STANDARDS CONFORMANCE

  ANSI X3J16/ISO WG21 Joint C++ Committee
  

1.800.AT.COMPAQ

privacy and legal statement