From: tweenk Date: Wed, 25 Feb 2009 22:52:12 +0000 (+0000) Subject: Revert commit 20742 that opened a can of worms. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d8d91998ae4183eda85b94c93c70405490ca9081;p=inkscape.git Revert commit 20742 that opened a can of worms. --- diff --git a/src/util/glib-list-iterators.h b/src/util/glib-list-iterators.h index 3779cad1e..586bc314a 100644 --- a/src/util/glib-list-iterators.h +++ b/src/util/glib-list-iterators.h @@ -1,14 +1,11 @@ -/** @file - * @brief STL iterators for Glib list types - */ -/* Inkscape::Util::GSListIterator - STL iterator for GSList +/* + * Inkscape::Util::GSListIterator - STL iterator for GSList * Inkscape::Util::GSListConstIterator - STL iterator for GSList * Inkscape::Util::GListIterator - STL iterator for GList * Inkscape::Util::GListConstIterator - STL iterator for GList * * Authors: * MenTaLguY - * Krzysztof Kosiński * * Copyright (C) 2005 MenTaLguY * @@ -24,6 +21,7 @@ #include "glib/glist.h" namespace Inkscape { + namespace Util { template class GSListConstIterator; @@ -46,9 +44,7 @@ public: GSList const *list() const { return _list; } reference operator*() const { - _ref_union u; - u._gp = _list->data; - return *u._p; + return *reinterpret_cast(&_list->data); } bool operator==(GSListConstIterator const &other) { @@ -69,7 +65,6 @@ public: } private: - union _ref_union {gpointer _gp; pointer _p;}; GSList const *_list; }; @@ -91,12 +86,10 @@ public: GSList *list() { return _list; } const_reference operator*() const { - return const_cast *>(this)->operator*(); + return *reinterpret_cast(&_list->data); } reference operator*() { - _ref_union u; - u._gp = _list->data; - return *u._p; + return *reinterpret_cast(&_list->data); } bool operator==(GSListIterator const &other) { @@ -117,7 +110,6 @@ public: } private: - union _ref_union {gpointer _gp; pointer _p;}; GSList *_list; }; @@ -136,9 +128,7 @@ public: GList const *list() const { return _list; } reference operator*() const { - _ref_union u; - u._gp = _list->data; - return *u._p; + return *reinterpret_cast(&_list->data); } bool operator==(GListConstIterator const &other) { @@ -169,7 +159,6 @@ public: } private: - union _ref_union {gpointer _gp; pointer _p;}; GList const *_list; }; @@ -197,13 +186,9 @@ public: GList *list() { return _list; } const_reference operator*() const { - return const_cast *>(this)->operator*(); - } - reference operator*() { - _ref_union u; - u._gp = _list->data; - return *u._p; + return *reinterpret_cast(&_list->data); } + reference operator*() { return *reinterpret_cast(&_list->data); } bool operator==(GListIterator const &other) { return other._list == _list; @@ -233,12 +218,12 @@ public: } private: - union _ref_union {gpointer _gp; pointer _p;}; GList *_list; }; -} // namespace Util -} // Namespace Inkscape +} + +} #endif /*