-
-union DataRefImpl {
- // This entire union should probably be a
- // char[max(8, sizeof(uintptr_t))] and require the impl to cast.
- struct {
- uint32_t a, b;
- } d;
- uintptr_t p;
- DataRefImpl() {
- std::memset(this, 0, sizeof(DataRefImpl));
- }
-};
-
-template<class content_type>
-class content_iterator {
- content_type Current;
-public:
- content_iterator(content_type symb)
- : Current(symb) {}
-
- const content_type* operator->() const {
- return &Current;
- }
-
- const content_type &operator*() const {
- return Current;
- }
-
- bool operator==(const content_iterator &other) const {
- return Current == other.Current;
- }
-
- bool operator!=(const content_iterator &other) const {
- return !(*this == other);
- }
-
- content_iterator& increment(error_code &err) {
- content_type next;
- if (error_code ec = Current.getNext(next))
- err = ec;
- else
- Current = next;
- return *this;
- }
-};
-
-inline bool operator==(const DataRefImpl &a, const DataRefImpl &b) {
- // Check bitwise identical. This is the only legal way to compare a union w/o
- // knowing which member is in use.
- return std::memcmp(&a, &b, sizeof(DataRefImpl)) == 0;
-}
-
-inline bool operator<(const DataRefImpl &a, const DataRefImpl &b) {
- // Check bitwise identical. This is the only legal way to compare a union w/o
- // knowing which member is in use.
- return std::memcmp(&a, &b, sizeof(DataRefImpl)) < 0;
-}