This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Wed, Aug 04, 2004 at 09:59:14AM -0700, Nathan Myers wrote:Yes, very smart and would work. However, as Nathan wrote, "let's not be hasty":
union { _CharT* _M_data; _CharT _M_nul };This looks good :). Dirty, but smart.
and define
inline _CharT* c_str() { return (this->data() ? this->data() : &this->_M_nul); }
inline _CharT& operator[](size_t i) { return this->c_str()[i]; }
One can hope that the optimizer might hoist the test out of loops.
(Fat chance.)
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |