$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (dave_at_[hidden])
Date: 2004-08-22 20:14:03
"Alex Chovanec" <achovane_at_[hidden]> writes:
> "David Abrahams" <dave_at_[hidden]> wrote in message
> news:ullg6287u.fsf_at_boost-consulting.com...
>> "Alex Chovanec" <achovane_at_[hidden]> writes:
>> >
>> > The 'is_iterator' struct template is a model of the "integral constant
>> > expression" concept. Thus, 'is_iterator<T>::value' evaluates to true
>> > if-and-only-if type T defines iterator traits
>>
>> I don't believe that's detectable without generating an error. Don't
>> forget that iterator_traits can be specialized; there's no reason the
>> iterator has to contain members. Quick test: what is
>> is_iterator<int*>::value?
>
> I don't really see why this a problem. 'is_iterator' can be specialized too,
> and that is what I have done for the case of pointers:
>
> template <typename T>
> struct is_iterator<T *>
> {
> typedef is_iterator type;
> typedef bool value_type;
>
> BOOST_STATIC_CONSTANT(value_type, value = true);
> };
>
> So 'is_iterator<int *>::value' evaluates to true without generating a
> compile error, as it should.
*Any* iterator can be implemented the same way. An iterator class
does not have to have a value_type member!
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com