[Spice-devel] [PATCH spice-streaming-agent v2 3/4] use std::string where it's easy to replace

Christophe Fergeau cfergeau at redhat.com
Wed Feb 14 14:28:35 UTC 2018


On Thu, Feb 08, 2018 at 08:16:37AM +0100, Christophe de Dinechin wrote:
> Using std::string by default is *not* considered a good practice in
> C++. The reference for C++ good practices are probably best summarized
> by the C++ Core Guidelines:
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md.
> Regarding strings, see
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rstr-zstring,
> which specifically states this:
> 
> 	Don't convert a C-style string to string unless there is a reason to.
> 
> “abc” is a C-style string, even in C++. You should pass it around as const char *, aka czstring as long as you can. *That* is the C++ good practice AFAIK.
> 

For maximal clarity, the link that you gave says *not* to use const char
*, but to use czstring instead... This does not say to "pass it around
as const char *".

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180214/46be3730/attachment.sig>


More information about the Spice-devel mailing list