Skip to content. Skip to navigation

ICTP Portal

Sections
You are here: Home Manuals on-line PGI Compiler pgC_lib value_type
Personal tools
Document Actions

value_type



Click on the banner to return to the class reference home page.

value_type


Type primitive

Summary

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.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

None

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


©Copyright 1996, Rogue Wave Software, Inc.


Powered by Plone This site conforms to the following standards: