[iterator_adaptor] Accessing base class
I have defined an iterator adaptor called skip_iterator. I found that I have to write: skip_iterator() : skip_iterator::iterator_adaptor_(0), m(1) {} rather than skip_iterator() : iterator_adaptor_(0), m(1) {} even though iterator_adaptor_ is a protected typedef inside iterator_adaptor. Will someone explain why I have to qualify the name? Thanks, Mark Ruzon
on Mon Aug 06 2007, Mark Ruzon
I have defined an iterator adaptor called skip_iterator. I found that I have to write:
skip_iterator() : skip_iterator::iterator_adaptor_(0), m(1) {}
rather than
skip_iterator() : iterator_adaptor_(0), m(1) {}
even though iterator_adaptor_ is a protected typedef inside iterator_adaptor. Will someone explain why I have to qualify the name?
Because it's a dependent type. http://www.codeproject.com/cpp/TwoPhaseLookup.asp http://www.comeaucomputing.com/techtalk/templates/#whymembernotfound HTH, -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
Mark Ruzon wrote:
I have defined an iterator adaptor called skip_iterator.
BTW, I implemented "steps" and "sliced", which is thought to be similar to "skip_iterator". If interested, see oven(http://tinyurl.com/2axp2l) at Boost.Vault/Algorithm. -- Shunsuke Sogame
On Mon, 6 Aug 2007, Mark Ruzon wrote:
I have defined an iterator adaptor called skip_iterator. I found that I have to write:
skip_iterator() : skip_iterator::iterator_adaptor_(0), m(1) {}
rather than
skip_iterator() : iterator_adaptor_(0), m(1) {}
even though iterator_adaptor_ is a protected typedef inside iterator_adaptor. Will someone explain why I have to qualify the name?
That is because it is inherited from a class template (and skip_iterator is a class template too, right?). Until the base class template is instantiated, the compiler doesn't know what's exactly inherited, so we need to give it some hints as to where that symbol comes from. -- François Duranleau LIGUM, Université de Montréal
participants (4)
-
David Abrahams
-
François Duranleau
-
Mark Ruzon
-
shunsuke