Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-07-08 10:20:04


"Fredrik Blomqvist" <fredrik_blomqvist_at_[hidden]> writes:

> Vladimir Prus wrote:
>> Fredrik Blomqvist wrote:
>>
>>> Wouldn't it be convenient if iterator_adaptor provided a protected
>>> "self typedef" for use by client code? In particular I'm thinking of
>>> the constructor case that basically always is feeding an iterator to
>>> the iterator_adaptor baseclass, thus needing its explicit type.
>>> (In most examples and tests this typedef is manually created as a
>>> 'super_t' for example).
>>>
>>> Having a predefined type would reduce the amount of boilerplate code
>>> and the risk of getting out-of-sync with the declaration. I suggest
>>> a name something like 'iterator_adaptor_t' instead of 'super_t' to
>>> lessen name-clash possibility.
>>
>> I'm not sure this is going to work:
>>
>> template<class T>
>> class yours : public iterator_facade<T, ...>
>> {
>> public:
>> yours(.....) : super_t(.......)
>> {
>> }
>> };
>>
>>
>> When compiler parses the above, name lookup does not use the scope of
>> iterator_facade, so no matter what's typedefed there, 'super_t' won't
>> be found.
>>
> Initially I had similar thoughts but since it compiled (and worked ok) in
> VC7.1
> I figured it might be legal and would be a neat improvement.

It ain't.

But what you _can_ do is:

      derived(T const& v) : derived::super_t(v) {}

I'm afraid that not every compiler supports that either, but I'm not
certain. It's an interesting thought. I'll put it in the queue of
iterator library issues I'm working on.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk