HP C++ User Documentation


value_type (3C++std) - Tru64 UNIX

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


  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


  #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*)


  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

  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)

  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.


  Other iterator primitives:  distance_type, iterator_category, distance,


  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.