Topic: Defect report [N2134]: regex_iterator and const correctness


Author: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Date: Mon, 5 Mar 2007 13:21:24 CST
Raw View
Both the class definition of regex_iterator ([re.regiter]-28.12.1/1)
and the latter member specification ([re.regiter.comp]-28.12.1.2/1+2)
declare both comparison operators as non-const functions.
Furtheron, both dereference operators are unexpectedly also
declared as non-const in 28.12.1/1 as well as in
([re.regiter.deref]-28.12.1.3/1+2).

Proposed resolution:

1) In (28.12.1/1) change the current declarations

bool operator==(const regex_iterator&);
bool operator!=(const regex_iterator&);
const value_type& operator*();
const value_type* operator->();

to

bool operator==(const regex_iterator&) const;
bool operator!=(const regex_iterator&) const;
const value_type& operator*() const;
const value_type* operator->() const;

2) In 28.12.1.3 change the following declarations

const value_type& operator*();
const value_type* operator->();

to

const value_type& operator*() const;
const value_type* operator->() const;

Greetings from Bremen,

Daniel Kr   gler


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Date: Mon, 5 Mar 2007 14:26:53 CST
Raw View
On 5 Mrz., 20:21, "Daniel Kr   gler" <daniel.krueg...@googlemail.com>
wrote:
> Both the class definition of regex_iterator ([re.regiter]-28.12.1/1)
> and the latter member specification ([re.regiter.comp]-28.12.1.2/1+2)
> declare both comparison operators as non-const functions.
> Furtheron, both dereference operators are unexpectedly also
> declared as non-const in 28.12.1/1 as well as in
> ([re.regiter.deref]-28.12.1.3/1+2).
>
> Proposed resolution:
>
> 1) In (28.12.1/1) change the current declarations
>
> bool operator==(const regex_iterator&);
> bool operator!=(const regex_iterator&);
> const value_type& operator*();
> const value_type* operator->();
>
> to
>
> bool operator==(const regex_iterator&) const;
> bool operator!=(const regex_iterator&) const;
> const value_type& operator*() const;
> const value_type* operator->() const;

I apologize for not explicitely mentioning the following
also necessary substitutions:

3) In 28.12.1.2 change the following declarations

bool operator==(const regex_iterator& right);
bool operator!=(const regex_iterator& right);

to

bool operator==(const regex_iterator& right) const;
bool operator!=(const regex_iterator& right) const;

Greetings from Bremen,

Daniel Kr   gler


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]