r/cpp • wx | soci | swig • Jun 17 '15

Standardizing Variant: Difficult Decisions

https://www.justsoftwaresolutions.co.uk/cplusplus/standardizing-variant.html
31 Upvotes

56 comments sorted by

View all comments

Show parent comment

1

u/whichton Jun 18 '15

Why can two different lists not share the same sentinel node? That is:

list<int> x;
list<int> y;

will have the same sentinel node, which will be a static member of list<int>. Does that not work ?

Also, are sentinel nodes mandated by the standard? You can have an end iterator without using sentinel nodes.

2

u/[deleted] Jun 18 '15

std::list is a doubly linked list, so it allows forward and backward iteration.

If two different lists shared the same end() node then you wouldn't be able to decrement from the end().

1

u/whichton Jun 18 '15

Doh! Thanks for the explanation, I need more coffee it seems :)