@Vlad, , . , , . , "" , NULL, , , , , , .
. , , , - ( ).
template<class T>
struct node{
T value;
node const& next;
struct circulator{
node const* impl_;
circulator& circulate(){impl_ = &(impl_->next); return *this;}
T const& operator*() const{return impl_->value;}
friend bool operator==(circulator const& c1, circulator const& c2){return c1.impl_ == c2.impl_;}
friend bool operator!=(circulator const& c1, circulator const& c2){return not(c1==c2);}
};
circulator some() const{return circulator{this};}
};
, (, ), const ! value , mutable (, ?). ( , ).
node/list, ( ). , , "rho".
node<int> n1{5, {6, {7, n1}}};
auto c = n1.some();
cout << "size " << sizeof(node<int>) << '\n';
do{
cout << *c << ", ";
c.circulate();
}while(c != n1.some());
, (?). ( - , , gcc clang). "" . , , :
circular_list<int> l{1,2,3,4};
, , , , , "" ? ? ?
, , -, .
!