"Best" way of passing in a big struct to a function?

Val Markovic val at markovic.io
Tue Oct 9 21:27:52 PDT 2012


TL;DR: what should I use if I need C++'s const& for a param?

Long version: I have a big struct provided by a library and I'm 
trying to pass instances of it to a function that will never need 
to modify the passed in value. Naturally I want to pass it 
efficiently, without incurring a copy. I know that I can use 
"const ref" in D, but is this the preferred way of doing it? How 
about "in ref"? Or something else?

Related background: I'm a D newbie, I've read TDPL and I loved it 
and I'm now working on a Markdown processor as a D learning 
exercise. I've written hundreds of thousands of C++ LOC and this 
is the perspective from which I look at D (and I love what I see).


More information about the Digitalmars-d-learn mailing list