Topic: value_type()
Author: ehsjony@ehs.ericsson.se (Jonas Nygren)
Date: 1995/04/25 Raw View
STL docs of October 94 describes a template function
template<class T> T* value_type(const T*) { return (T*)0; }
which can be used to 'extract' the type of the items an iterator points
at. Iterators all have an 'operator T*' function.
If I have understood correctly it works as follows:
template<class T> struct iterator {
operator T*() { return 0; }
};
template<class I> void a_func(I i1, I i2) { __a_func(i1,i2,value_type(i1)); }
template<class I, class T> void __a_func(I i1, I i2, T) { }
iterator<int> i1, i2;
.
.
a_func(i1, i2);
The call of a_func should generate a call to the template for
__a_func(iterator<int> i1, iterator<int> i2, int)
This does not work for me with g++-2.6.3, it fails to instantiate __a_func.
I know the standard has been updated with regard to templates so
my question is: should this work according to todays C++ standard?
(If so, do you know when it will be available in g++?)
/jonas