stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Pevtsov" <Ant...@moscow.vdiweb.com>
Subject test for lib.string.access
Date Thu, 04 May 2006 14:12:37 GMT
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