You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4x warning: type qualifiers ignored on function return type on cbegin() and cend()
(and a couple of signed/unsigned comparison warning in the test code)
I managed to quieten the warnings by
adding a const_pointer typedef with const added to the type
updating const_iterator typedef from const pointer to const_pointer
(or, just update const_iterator but I prefer to also have a const_pointer typedef).
using const_pointer = _Tp const*; // added
using const_iterator = const_pointer; // updated
The text was updated successfully, but these errors were encountered:
Thanks for the report - we're going to be looking at bugs in <span> in Rapperswil next month. I'll make sure that this gets discussed (and probably updated in the standard).
Thanks for posting these snippets - I'd studied the earlier array_view snippet too.
The same bug was lying latent in my code - without warning - so it's useful that gcc flushed it out here. Clang doesn't warn (with the same flags). Coincidentally, on cpplang slack #general today arthur-odwyer found this same const pointer bug in some other multidimensional array code. Maybe there's a common ancestor. Can't remember if I'd copied or concocted-it-up.
It does sound like a storm is brewing over span's cbegin return:
Again on slack today, in #future_standard, a >100 thread was sparked by tvaneerd's "irregular span" paper, which itself references 'a giant reflector discussion', with caseycarter noting: I think it's an abomination that cbegin(span) and span.cbegin() have different meaning
https://wandbox.org/permlink/EjDDKW72cTOKB3et
^^^ cut n paste the span snippet to wandbox with recent gcc gives vvv
4x
warning: type qualifiers ignored on function return type
oncbegin()
andcend()
(and a couple of signed/unsigned comparison warning in the test code)
I managed to quieten the warnings by
const_pointer
typedef with const added to the typeconst_iterator
typedef fromconst pointer
toconst_pointer
(or, just update
const_iterator
but I prefer to also have aconst_pointer
typedef).The text was updated successfully, but these errors were encountered: