On 2010-09-07 14:49, Steven Schveighoffer wrote:
On Sun, 05 Sep 2010 09:40:59 -0400, BLS <windev...@hotmail.de> wrote:

On 05/09/2010 02:16, Jonathan M Davis wrote:
void foo(T)(T[] collection, T elem)
{
// Blah, whatever
}


I am curious, how this will look and feel once inout is working ?

inout void foo(T)(inout(T)[] collection, inout T elem)
{
// Blah, whatever}
}


inout void doesn't make any sense. You can't have a const void or
immutable void.

Now, if foo is a member function, then inout applies to the "this"
pointer, but even then, you need a return type other than void for inout
to be used.

-Steve

inout is only used when you want to return the same constness (mutable, const, immutable) as you passed in to the function. If you don't want that, or don't want to return anything then const(T)[] is what you want. It will accept mutable, const and immutable.

--
/Jacob Carlborg

Reply via email to