The current implementation of common_iterator stores both the iterator and sentinel as direct members. Since only one of the members can be active at any time, this always wastes space.
P0896 has a note that common_iterator's members should be respecified in terms of std::variant. While we can't use variant (as it's C++17 only), we should use a simple tagged union to avoid making common_iterator twice as big as it needs to be.
The current implementation of
common_iteratorstores both the iterator and sentinel as direct members. Since only one of the members can be active at any time, this always wastes space.P0896 has a note that
common_iterator's members should be respecified in terms ofstd::variant. While we can't usevariant(as it's C++17 only), we should use a simple tagged union to avoid makingcommon_iteratortwice as big as it needs to be.