Hello,
I came across what seems like an interesting oddity:
#include
using boost::iterator_core_access;
namespace ns
{
struct range
{
class iterator : public boost::iterator_facade
{
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::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.