This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: using C++ STL containers in GCC/gfortran source code
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Pedro Alves <pedro at palves dot net>
- Cc: Janus Weil <janus at gcc dot gnu dot org>, gcc mailing list <gcc at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Fri, 16 Dec 2016 19:56:04 +0100
- Subject: Re: using C++ STL containers in GCC/gfortran source code
- Authentication-results: sourceware.org; auth=none
- References: <CAKwh3qgUN=mTFPg6Ew6Yk9RXgS3CttE7O3cGMQRcLKNqUOjBng@mail.gmail.com> <CAKwh3qii7EFG4VECNOgqF6kXczvwK0jQbQyDcQTnwuzSdSCfRw@mail.gmail.com> <20161216180415.GZ21933@tucnak> <40d8cce1-92fc-7585-937c-0f39dbb87141@palves.net>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Dec 16, 2016 at 06:52:03PM +0000, Pedro Alves wrote:
> GDB has a string_printf function that prints into a std::string, for
> example. Like:
>
> std::string hello = string_printf ("%s", "hello world");
>
> That's a function that many C++ projects reinvent.
If you then want to work with it as std::string object, sure, it makes
sense. But if all you want is to pass the string to %s of another
formatting function and free it, then going through std::string
doesn't add many benefits over just xasprintf + free.
Jakub