Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

HP C++ User Documentation

 

value_type (3C++std) - Tru64 UNIX

Standard C++ Library
Copyright 1996, Rogue Wave Software, Inc.

NAME

  value_type  - Determine the type of value an iterator points to. 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 T* value_type (const input_iterator<T, Distance>&)

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

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

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

  template <class T>
  inline T* value_type (const T*)

DESCRIPTION

  The value_type  function template returns a pointer to a default value of
  the type pointed to by an iterator.  Five overloaded versions of this
  function template handle the four basic iterator types and simple arrays.
  Each of the first four take an iterator of a specific type, and return the
  value used to instantiate the iterator.  The fifth version takes and
  returns a T* in order to handle the case when an iterator is a simple
  pointer.

  This family of  function templates can be used to extract a value type from
  an iterator and subsequently use that type to create a local variable.
  Typically the value_type functions are used like this:

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

  template <class Iterator, class T>
  void __foo(Iterator first, Iterator last, T*>
  {
   T temp = *first;
     _
  }

  The auxiliary function __foo extracts a usable value type from the iterator
  and then puts the type to work.

SEE ALSO

  Other iterator primitives:  distance_type, iterator_category, distance,
  advance

STANDARDS CONFORMANCE

  ANSI X3J16/ISO WG21 Joint C++ Committee
About PDF files: The PDF files on this site can be read online or printed using Adobe® Acrobat® Reader. If you do not have this software on your system, you may download it from Adobe's website.
Privacy statement Using this site means you accept its terms C++ support
© 2008 Hewlett-Packard Development Company, L.P.