This is the mail archive of the
mailing list for the libstdc++ project.
Re: std::string and literals
- From: "Jack Reeves" <jackw_reeves at hotmail dot com>
- To: brd at paradise dot net dot nz
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Fri, 19 Jul 2002 15:56:03 +0000
- Subject: Re: std::string and literals
- Reply-to: jack_reeves at bleading-edge dot com
No. a 'string' is an object and naturally manages its own state.
Q. Is there a way to specifically create a std::string instance that will
just be a reference to the given literal? (with copy on write semantics
In my private tool box I have a class called basic_stringref
(with the obvious typedef basic_stringref<char> stringref).
It does what you want - wraps a 'string' facade around an
existing character array without making a copy. Of course,
it is not a 'string' and so can not be passed to a function that
expects one. If you are interested in more details email me directly.
MSN Photos is the easiest way to share and print your photos: