properly passing strings to functions? (C++ vs D)

Q. Schroll qs.il.paperinik at gmail.com
Tue Jan 12 18:12:14 UTC 2021


On Monday, 11 January 2021 at 16:53:50 UTC, IGotD- wrote:
> I usually use "const string text" because D has no implicit 
> declaration of variables. So using "ref" will not create a 
> variable. This is contrary to C++ where passing as "const 
> std::string &text" has a performance benefit and also C++ 
> creates a unnamed variable for you.

Did you consider `in`? It will do that in some time and do it now 
with -preview=in.
If you're using `const`, in almost all cases, `in` will work, 
too, and be better (and shorter).


More information about the Digitalmars-d-learn mailing list