Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-06 Thread rempas via Digitalmars-d-learn
On Friday, 6 May 2022 at 13:35:13 UTC, Steven Schveighoffer wrote: You don't need to declare an assign operator, the default for structs is to member-wise copy all the values. However, if you do provide one, it will be used. Note that a simple default can be done like: ```d ref My_File

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/5/22 4:27 PM, rempas wrote: On Thursday, 5 May 2022 at 14:20:49 UTC, Steven Schveighoffer wrote: Your assignment operator does nothing. Thanks! That was indeed the problem! In the other data structures, it worked without needing explicitly provide one so I didn't thought about it.

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-06 Thread rempas via Digitalmars-d-learn
On Thursday, 5 May 2022 at 21:07:22 UTC, colleen camacho wrote: can i use method of Dynamic array in C using malloc library function. Program example will create an integer array of any length dynamically by asking the array size and array elements from user and display on the screen.how

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-05 Thread colleen camacho via Digitalmars-d-learn
On Thursday, 5 May 2022 at 10:40:44 UTC, rempas wrote: I have created a structure that is a actually an array that allocates memory and growths. It is a template and it has worked with a couple of types that I have tried with. It doesn't work with one tho and I cannot understand why. I will

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-05 Thread rempas via Digitalmars-d-learn
On Thursday, 5 May 2022 at 14:20:49 UTC, Steven Schveighoffer wrote: Your assignment operator does nothing. -Steve Thanks! That was indeed the problem! In the other data structures, it worked without needing explicitly provide one so I didn't thought about it. Thanks a lot, you're saving

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-05 Thread rempas via Digitalmars-d-learn
On Thursday, 5 May 2022 at 11:49:29 UTC, vit wrote: ```d this.capacity += DEF_VEC_REALLOC_SIZE; //realloc(this.ptr, T.sizeof * DEF_VEC_REALLOC_SIZE); this.ptr = realloc(this.ptr, T.sizeof * this.capacity); //<<-- ``` Oh, right! I forgot to say it. I'm using my own

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/5/22 6:40 AM, rempas wrote:   ref My_File opAssign(ref const My_File s) return { return this; } Your assignment operator does nothing. -Steve

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-05 Thread vit via Digitalmars-d-learn
On Thursday, 5 May 2022 at 11:49:29 UTC, vit wrote: On Thursday, 5 May 2022 at 10:40:44 UTC, rempas wrote: I have created a structure that is a actually an array that allocates memory and growths. It is a template and it has worked with a couple of types that I have tried with. It doesn't

Re: Why isn't my dynamic array method doesn't work for this type?

2022-05-05 Thread vit via Digitalmars-d-learn
On Thursday, 5 May 2022 at 10:40:44 UTC, rempas wrote: I have created a structure that is a actually an array that allocates memory and growths. It is a template and it has worked with a couple of types that I have tried with. It doesn't work with one tho and I cannot understand why. I will

Why isn't my dynamic array method doesn't work for this type?

2022-05-05 Thread rempas via Digitalmars-d-learn
I have created a structure that is a actually an array that allocates memory and growths. It is a template and it has worked with a couple of types that I have tried with. It doesn't work with one tho and I cannot understand why. I will list the smallest possible code I could. Keep in mind