Using in as a parameter qualifier

Shriramana Sharma samjnaa at gmail.com
Fri May 31 16:41:44 PDT 2013


On Fri, May 31, 2013 at 8:55 PM, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> In D, const ref does not accept rvalues (unlike C++'s const &).

So what is the syntax that accepts rvalues and yet does not make a
copy of the input object? I mean, as Ali says OK profiling is
preferable to find out where exactly passing by value is more
efficient than passing by const ref, but I'd like to know anyway what
is the syntax available for this so at least until I get my D legs, I
can continue some of my practices from C++ without much detriment.

I just finished reading this link which Ali gave:
http://bartoszmilewski.com/2008/11/03/who-ordered-rvalue-references-part-3/
but perhaps due to my ignorance I don't get 100% what he is tryring to
say. Is it really relevant for what I am asking, like avoiding a
copy-constructor in the input of a function which will not modify its
input, even if I pass by value?

I'm currently working on a project at some priority, and it's
currently at a relatively flexible stage so I am thinking of switching
it over to D thinking it would make me finish the job quicker, but if
I will have to bend my thinking too much around differences between
C++ and D and around unfinished language features (scope?) I think I
may stick with C++ at least for the present project and maybe use D
for future ones. Advice?

-- 
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा


More information about the Digitalmars-d-learn mailing list