/// Create from an ilist_node.
explicit ilist_iterator(node_reference N) : NodePtr(&N) {}
- explicit ilist_iterator(pointer NP) : NodePtr(NP) {}
- explicit ilist_iterator(reference NR) : NodePtr(&NR) {}
+ explicit ilist_iterator(pointer NP)
+ : NodePtr(ilist_node_access::getNodePtr(NP)) {}
+ explicit ilist_iterator(reference NR)
+ : NodePtr(ilist_node_access::getNodePtr(&NR)) {}
ilist_iterator() : NodePtr(nullptr) {}
// This is templated so that we can allow constructing a const iterator from
// Accessors...
reference operator*() const {
assert(!NodePtr->isKnownSentinel());
- return static_cast<NodeTy &>(*getNodePtr());
+ return *ilist_node_access::getValuePtr(NodePtr);
}
pointer operator->() const { return &operator*(); }
template <typename T> static const ilist_node<T> *getNodePtr(const T *N) {
return N;
}
+ template <typename T> static T *getValuePtr(ilist_node<T> *N) {
+ return static_cast<T *>(N);
+ }
+ template <typename T> static const T *getValuePtr(const ilist_node<T> *N) {
+ return static_cast<const T *>(N);
+ }
template <typename T> static ilist_node<T> *getPrev(ilist_node<T> &N) {
return N.getPrev();
TEST(IListTest, privateNode) {
// Instantiate various APIs to be sure they're callable when ilist_node is
// inherited privately.
- ilist<NodeWithCallback> L;
- NodeWithCallback N(7);
+ ilist<PrivateNode> L;
+ PrivateNode N(7);
L.insert(L.begin(), &N);
++L.begin();
(void)*L.begin();
(void)(L.begin() == L.end());
- ilist<NodeWithCallback> L2;
+ ilist<PrivateNode> L2;
L2.splice(L2.end(), L);
L2.remove(&N);
}