[iterator] iterator_core_access and namespaces
Hello, I came across what seems like an interesting oddity: #include <boost/iterator/iterator_facade.hpp> using boost::iterator_core_access; namespace ns { struct range { class iterator : public boost::iterator_facade<iterator, int, boost::single_pass_traversal_tag> { friend class iterator_core_access; int& dereference() const; void increment(); bool equal(const iterator& other) const; }; typedef iterator iterator; iterator begin(); iterator end(); }; } int main() { ns::range::iterator b; ++b; } This code goes not compile with gcc (I tried with 4.3 through 4.7), giving the following error: test.cpp: In static member function 'static void boost::iterator_core_access::increment(Facade&) [with Facade = ns::range::iterator]': boost/boost/iterator/iterator_facade.hpp:664:11: instantiated from 'Derived& boost::iterator_facade<I, V, TC, R, D>::operator++() [with Derived = ns::range::iterator, Value = int, CategoryOrTraversal = boost::single_pass_traversal_tag, Reference = int&, Difference = int]' test.cpp:29:7: instantiated from here test.cpp:16:18: error: 'void ns::range::iterator::increment()' is private boost/boost/iterator/iterator_facade.hpp:523:11: error: within this context If I explicitly qualify iterator_core_access in the friend declaration (i.e. "friend class boost::iterator_core_access"), or if I move the "using boost::iterator_core_access" inside the namespace, it works fine. Is this a compiler bug, or am I bumping into a shadowy corner of the Standard involving friends and namespaces? Thanks, Nate.
participants (1)
-
Nathan Ridge