This is an automated email from the ASF dual-hosted git repository. amc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 1e2ef5c8281531a7797f735011e27748a98ec801 Author: Alan M. Carroll <[email protected]> AuthorDate: Fri Jul 20 08:36:21 2018 -0500 IntrusiveDList: Add user conversion from iterator to pointer to value_type. --- lib/ts/IntrusiveDList.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/ts/IntrusiveDList.h b/lib/ts/IntrusiveDList.h index 320be15..98f92d4 100644 --- a/lib/ts/IntrusiveDList.h +++ b/lib/ts/IntrusiveDList.h @@ -142,6 +142,11 @@ public: /// @return A pointer to the referent. value_type *operator->() const; + /// Convenience conversion to pointer type + /// Because of how this list is normally used, being able to pass an iterator as a pointer is quite convienent. + /// If the iterator isn't valid, it converts to @c nullptr. + operator value_type *() const; + /// Equality bool operator==(self_type const &that) const; @@ -206,6 +211,11 @@ public: /// @return A pointer to the referent. value_type *operator->() const; + /// Convenience conversion to pointer type + /// Because of how this list is normally used, being able to pass an iterator as a pointer is quite convienent. + /// If the iterator isn't valid, it converts to @c nullptr. + operator value_type *() const; + protected: /// Internal constructor for containers. iterator(list_type *list, value_type *v); @@ -395,6 +405,11 @@ template <typename L> auto IntrusiveDList<L>::iterator::operator-> () const -> v return super_type::_v; } +template <typename L> IntrusiveDList<L>::const_iterator::operator value_type *() const +{ + return _v; +} + template <typename L> auto IntrusiveDList<L>::const_iterator::operator*() const -> value_type & { return *_v; @@ -405,6 +420,11 @@ template <typename L> auto IntrusiveDList<L>::iterator::operator*() const -> val return *super_type::_v; } +template <typename L> IntrusiveDList<L>::iterator::operator value_type *() const +{ + return super_type::_v; +} + template <typename L> bool IntrusiveDList<L>::empty() const
