"Best" way of passing in a big struct to a function?
Val Markovic
val at markovic.io
Tue Oct 9 21:51:50 PDT 2012
> This whole topic is a bit of a thorny one in that D's design is
> trying to
> avoid some of the problems that allowing const T& to take
> rvalues in C++
> causes, but it makes a situation like what you're trying to do
> annoying to
> handle. And auto ref doesn't really fix it (even though that's
> whole the reason
> that it was added), because it only works with templated
> functions. There have
> been some discussions on how to adjust how ref works in order
> to fix the
> problem without introducing the problems that C++ has with it,
> but nothing has
> actually be decided on yet, let alone implemented.
So if I don't need to support accepting rvalues, is there an
argument for "in ref" over "const ref"? "in ref" looks superior:
it's more descriptive and from what the docs say, it gives even
more guarantees about the behavior of the function.
More information about the Digitalmars-d-learn
mailing list