How can I do this?
I have this code: http://dpaste.dzfl.pl/d9165502
And as you can see, the templated function 'receive2' take
automatically dynamic arrays. But how can I tell the compiler,
that this function takes (preferably) static arrays?
My little hack function 'receive' take the type
On 2012-05-15 16:10, Namespace rswhi...@googlemail.com wrote:
How can I do this?
I have this code: http://dpaste.dzfl.pl/d9165502
And as you can see, the templated function 'receive2' take automatically
dynamic arrays. But how can I tell the compiler, that this function
takes (preferably)
So there is no way that the compiler knows by himself how many
elements are in the array? something like this:
void receive(T, size_t n = vals.length)(T[n] vals) {
writeln(typeof(vals).stringof);
}
or:
void receive(T)(T[vals.length] vals) {
writeln(typeof(vals).stringof);
}
On Monday, 15 October 2012 at 15:10:43 UTC, bearophile wrote:
Namespace:
So there is no way that the compiler knows by himself how many
elements are in the array?
The syntax I have suggested doesn't have the problem you fear.
Why don't you compile and run a little test program?
Bye,
Namespace:
So there is no way that the compiler knows by himself how many
elements are in the array?
The syntax I have suggested doesn't have the problem you fear.
Why don't you compile and run a little test program?
Bye,
bearophile
On 2012-23-15 16:10, Simen Kjaeraas simen.kja...@gmail.com wrote:
On 2012-05-15 16:10, Namespace rswhi...@googlemail.com wrote:
How can I do this?
I have this code: http://dpaste.dzfl.pl/d9165502
And as you can see, the templated function 'receive2' take
automatically dynamic arrays. But
But bar([1, 2, 3]); not. The compiler does not realize that [1,
2, 3] means a static array in this context.
You have to write bar(cast(int[3]) [1, 2, 3]); but I think the
compiler have to recognize this on it's own.
On 2012-35-15 17:10, Namespace rswhi...@googlemail.com wrote:
But bar([1, 2, 3]); not. The compiler does not realize that [1, 2, 3]
means a static array in this context.
You have to write bar(cast(int[3]) [1, 2, 3]); but I think the compiler
have to recognize this on it's own.
This is
On Mon, Oct 15, 2012 at 07:05:13PM +0200, Simen Kjaeraas wrote:
On 2012-35-15 17:10, Namespace rswhi...@googlemail.com wrote:
But bar([1, 2, 3]); not. The compiler does not realize that [1, 2, 3]
means a static array in this context. You have to write
bar(cast(int[3]) [1, 2, 3]); but I
On Monday, 15 October 2012 at 17:05:30 UTC, Simen Kjaeraas wrote:
On 2012-35-15 17:10, Namespace rswhi...@googlemail.com wrote:
But bar([1, 2, 3]); not. The compiler does not realize that
[1, 2, 3] means a static array in this context.
You have to write bar(cast(int[3]) [1, 2, 3]); but I think
10 matches
Mail list logo