Thanks for your help.
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote:
What is the best way in D to create a function that receives a
static array of any length?
Do know that static arrays are passed by value in D, so passing a
static array of a million elements will copy them...
There are two solution
On Wednesday, 12 July 2017 at 12:57:19 UTC, Rene Zwanenburg wrote:
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote:
What is the best way in D to create a function that receives a
static array of any length?
Templatize the array length:
void foo(size_t length)(int[length] arr)
{
}
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote:
What is the best way in D to create a function that receives a
static array of any length?
You will need to use templates:
void foo(size_t N)(int[N] arr) {
}
--
Biotronic
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote:
What is the best way in D to create a function that receives a
static array of any length?
Templatize the array length:
void foo(size_t length)(int[length] arr)
{
}
What is the best way in D to create a function that receives a
static array of any length?
On Saturday, 7 June 2014 at 21:32:08 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
On Sat, 07 Jun 2014 20:56:13 +
Paul via Digitalmars-d-learn
wrote:
Dynamic array is really reference. Right? But why modification
of
parameter in this case does not work:
void some_func(string[] s
On Saturday, 7 June 2014 at 21:17:41 UTC, monarch_dodra wrote:
On Saturday, 7 June 2014 at 20:56:14 UTC, Paul wrote:
Dynamic array is really reference. Right? But why modification
of parameter in this case does not work:
void some_func(string[] s) {
s ~= "xxx"; s ~= "yyy";
}
but this works:
On Sat, 07 Jun 2014 20:56:13 +
Paul via Digitalmars-d-learn wrote:
> Dynamic array is really reference. Right? But why modification of
> parameter in this case does not work:
>
> void some_func(string[] s) {
> s ~= "xxx"; s ~= "yyy";
> }
>
> but this works:
>
> void some_fun(ref string[] s)
On Saturday, 7 June 2014 at 20:56:14 UTC, Paul wrote:
Dynamic array is really reference. Right? But why modification
of parameter in this case does not work:
void some_func(string[] s) {
s ~= "xxx"; s ~= "yyy";
}
but this works:
void some_fun(ref string[] s) {
s ~= "xxx"; s ~= "yyy";
}
In
Dynamic array is really reference. Right? But why modification of
parameter in this case does not work:
void some_func(string[] s) {
s ~= "xxx"; s ~= "yyy";
}
but this works:
void some_fun(ref string[] s) {
s ~= "xxx"; s ~= "yyy";
}
In the 1st case s is reference too, is not it?
11 matches
Mail list logo