|
Boost : |
From: Boris Fomitchev (fbp_at_[hidden])
Date: 2000-10-02 10:45:54
Looks like ISPTR used as a discriminator for full class
specialization
will work if ISCONST used as a secondary discriminator and member
template classes work :
template <bool is_ptr, bool is_const>
struct iterator_traits_helper
{
template <class Iterator> class iterator_traits_base {
typedef typename Iterator::value_type value_type;
...
}
};
template<>
struct iterator_traits_helper<true, true>
{
// we know for sure this guy is const T*
// remove_const template is supposed to remove const -- do we have
that ???
template <class Iterator> class iterator_traits_base {
typedef typename remove_const<Iterator>::value_type value_type;
...
}
};
template <class T>
struct iterator_traits : public
iterator_traits_helper::iterator_traits_base<IS_PTR<T>::Ret,
IS_CONST<T> > {
};
The problem might be that VC6 might not work very well with typedefs
inside member template classes...
-Boris.
--- In boost_at_[hidden], jbandela_at_u... wrote:
> Anybody have any ideas of how to use this technique to implement
> iterator_traits in the STL? This technique allows differentiation
> between user defined iterators and pointers as iterators. Does
> anybody know of any technique that can allow value_type to be
> specified. (The only way I can think to do this would be with the
non-
> existant typeof).
>
> Regards,
>
> John R. Bandela
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk