Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterator operators not returning iterator reference #8

Closed
dinghram opened this issue Jun 20, 2018 · 3 comments
Closed

iterator operators not returning iterator reference #8

dinghram opened this issue Jun 20, 2018 · 3 comments

Comments

@dinghram
Copy link

For parity with std::list, (at least in Visual Studio), the following should return a reference to the list_iterator, rather than a copy:

inline PLF_LIST_FORCE_INLINE list_iterator operator ++ () PLF_LIST_NOEXCEPT
inline PLF_LIST_FORCE_INLINE list_iterator operator -- () PLF_LIST_NOEXCEPT
inline list_iterator operator = (const list_iterator &rh) PLF_LIST_NOEXCEPT
inline list_iterator operator = (const list_iterator &&rh) PLF_LIST_NOEXCEPT

inline PLF_LIST_FORCE_INLINE list_reverse_iterator operator ++ () PLF_LIST_NOEXCEPT
inline PLF_LIST_FORCE_INLINE list_reverse_iterator operator -- () PLF_LIST_NOEXCEPT
inline list_reverse_iterator operator = (const list_reverse_iterator &rh) PLF_LIST_NOEXCEPT
inline list_reverse_iterator operator = (const list_reverse_iterator &&rh) PLF_LIST_NOEXCEPT

@mattreecebentley
Copy link
Owner

Thanks the original reason I didn't do this was because I figured since the iterator is just a pointer anyway, returning a pointer to a pointer (reference) would incur a performance cost -
having done some benchmarking this is not the case, and you're correct that this is a standards compliance "thing".
https://en.cppreference.com/w/cpp/language/operator_incdec

@mattreecebentley
Copy link
Owner

Fixed

@dinghram
Copy link
Author

dinghram commented Jun 21, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants