stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Pevtsov" <Ant...@moscow.vdiweb.com>
Subject RE: test for lib.string.access
Date Sat, 06 May 2006 15:18:46 GMT
The ported test is here:
http://people.apache.org/~antonp/stdcxx05062006/

Thanks,
Anton Pevtsov


-----Original Message-----
From: Anton Pevtsov [mailto:AntonP@moscow.vdiweb.com] 
Sent: Thursday, May 04, 2006 18:13
To: stdcxx-dev@incubator.apache.org
Subject: test for lib.string.access


I am porting the test for lib.string.access methods (operator[] and at)
and found one issue.

The code 

#include <string>

int main (void)
{
    std::string s ("a", 1);
    const char& c = s[1];

    return 0;
}

results in assertion and fails. But the standard says for 
const_reference operator[] (size_type pos) const:

"If pos < size() returns data()[pos]. Otherwise, if pos == size(), the
const version returns charT(). Otherwise, the behavior is undefined."

So I expect charT() without any asserts.

What do you think about this?


Thanks,
Anton Pevtsov.

Mime
View raw message