Re: Calling assumeSorted on const(std.container.Array)

2023-03-26 Thread Olivier Prat via Digitalmars-d-learn
On Sunday, 26 March 2023 at 02:16:15 UTC, Steven Schveighoffer wrote: On 3/25/23 9:45 AM, Olivier Prat wrote: [...] It's because a Range keeps a copy of the array (Array is a reference counted type). Since that is labeled `const`, then editing the Range is forbidden. Inside SortedRange, i

Re: Calling assumeSorted on const(std.container.Array)

2023-03-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/25/23 9:45 AM, Olivier Prat wrote: Would someone explain the exact nature of this error as I fail to understand as how just telling that an Array ConstRange is assumed to be sorted actually modifies anything?? It's because a Range keeps a copy of the array (Array is a reference counted

Re: Calling assumeSorted on const(std.container.Array)

2023-03-25 Thread Ali Çehreli via Digitalmars-d-learn
On 3/25/23 09:31, Olivier Prat wrote: On Saturday, 25 March 2023 at 13:45:36 UTC, Olivier Prat wrote: I'm trying to call assumeSorted on a const(Array) using this code snippet: [...] In a similar fashion, a number of methods in SortedRange do not compile if called on a const(SortedRange) or

Re: Calling assumeSorted on const(std.container.Array)

2023-03-25 Thread Olivier Prat via Digitalmars-d-learn
On Saturday, 25 March 2023 at 13:45:36 UTC, Olivier Prat wrote: I'm trying to call assumeSorted on a const(Array) using this code snippet: [...] In a similar fashion, a number of methods in SortedRange do not compile if called on a const(SortedRange) or immutable(SortedRange), such as lengt

Calling assumeSorted on const(std.container.Array)

2023-03-25 Thread Olivier Prat via Digitalmars-d-learn
I'm trying to call assumeSorted on a const(Array) using this code snippet: void test(T)(const ref Array!T a) { auto b = a[].assumeSorted; writeln(b); } void main() { Array!int a = [1, 5, 7, 8, 15, 100]; test(a); } Unfortunately, I keep having

Re: Package import order with extern(C++) classes and std.container.array failure

2021-04-06 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 6 April 2021 at 09:33:32 UTC, cc wrote: Just encountered this compilation failure in DMD winx64 2.096, which previously worked in 2.095 and prior versions. DMD 2.094.2 fails with the same error? But current master works for me. Just wondering if it's a bug, or a new issue to keep

Package import order with extern(C++) classes and std.container.array failure

2021-04-06 Thread cc via Digitalmars-d-learn
m.d module cream.dcream; import cream; import std.container.array; Array!CallbackBase callbackTracker; Compilation fails with the following error: C:\D\dmd2\windows\bin\..\..\src\phobos\std\container\array.d(519): Error: incompatible types for array comparison: `const(CallbackBase[])` and `const(Callback

Re: Associative array using std.container.array

2020-10-28 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 28, 2020 at 06:54:01PM +, Vino via Digitalmars-d-learn wrote: > Hi All, > >Is it possible to create an associative array using > std.container.array, if possible can you please provide me an example > nor send me some link which has this information. https://d

Associative array using std.container.array

2020-10-28 Thread Vino via Digitalmars-d-learn
Hi All, Is it possible to create an associative array using std.container.array, if possible can you please provide me an example nor send me some link which has this information. From, Vino.B

std.container.array pointer

2020-05-23 Thread bauss via Digitalmars-d-learn
Is it possible to have a pointer to a nogc array? Like for regular arrays you can just do .ptr How would you do the same for a nogc array? The reason is I need to read different types of values from a nogc byte array. Ex. reading an int at offset 12 of the array. With normal arrays it can b

Re: std.container.array: Error: unable to determine fields of Test because of forward references

2019-10-31 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 31 October 2019 at 12:37:55 UTC, user1234 wrote: struct S { S*[] children; } because otherwise when you declare the array the compiler has not finished the semantic ana of S. --- struct Test { Test[] t; } --- Works today. Putting pointers into the container (and thus ha

Re: std.container.array: Error: unable to determine fields of Test because of forward references

2019-10-31 Thread user1234 via Digitalmars-d-learn
On Thursday, 31 October 2019 at 12:37:55 UTC, user1234 wrote: On Thursday, 31 October 2019 at 12:29:28 UTC, Tobias Pankrath wrote: [...] Try struct S { S*[] children; } because otherwise when you declare the array the compiler has not finished the semantic ana of S. so S size is not

Re: std.container.array: Error: unable to determine fields of Test because of forward references

2019-10-31 Thread user1234 via Digitalmars-d-learn
On Thursday, 31 October 2019 at 12:29:28 UTC, Tobias Pankrath wrote: My Problem: --- (https://run.dlang.io/is/CfLscj) import std.container.array; import std.traits; struct Test { Test[] t; } struct Test2 { Array!Test2 t; } int main() { return FieldTypeTuple!Test.length

std.container.array: Error: unable to determine fields of Test because of forward references

2019-10-31 Thread Tobias Pankrath via Digitalmars-d-learn
My Problem: --- (https://run.dlang.io/is/CfLscj) import std.container.array; import std.traits; struct Test { Test[] t; } struct Test2 { Array!Test2 t; } int main() { return FieldTypeTuple!Test.length + FieldTypeTuple!Test2; } --- I've found https://issues.dlan

Re: How to get a range from std.container.array for use with std.format.sformat?

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/18 2:19 PM, cc wrote: Still doesn't work without the cast it seems.. auto rng = str[]; rng.sformat!"%s:%s"("some", "string"); // Error: template std.format.sformat cannot deduce function from argument types !("%s:%s")(RangeT!(Array!char), string, string) I misunderstood

Re: How to get a range from std.container.array for use with std.format.sformat?

2018-01-30 Thread Seb via Digitalmars-d-learn
On Tuesday, 30 January 2018 at 18:42:45 UTC, Steven Schveighoffer wrote: On 1/30/18 12:53 PM, cc wrote: import std.container; import std.format; Array!char str; str.length = 256; str.sformat!"%s:%s"("some", "string"); // Error: template std.format.sformat cannot de

Re: How to get a range from std.container.array for use with std.format.sformat?

2018-01-30 Thread cc via Digitalmars-d-learn
Still doesn't work without the cast it seems.. auto rng = str[]; rng.sformat!"%s:%s"("some", "string"); // Error: template std.format.sformat cannot deduce function from argument types !("%s:%s")(RangeT!(Array!char), string, string)

Re: How to get a range from std.container.array for use with std.format.sformat?

2018-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/18 12:53 PM, cc wrote: import std.container; import std.format; Array!char str; str.length = 256; str.sformat!"%s:%s"("some", "string"); // Error: template std.format.sformat cannot deduce function from argument types !("%s:%s")(Array!char, string, string),

How to get a range from std.container.array for use with std.format.sformat?

2018-01-30 Thread cc via Digitalmars-d-learn
import std.container; import std.format; Array!char str; str.length = 256; str.sformat!"%s:%s"("some", "string"); // Error: template std.format.sformat cannot deduce function from argument types !("%s:%s")(Array!char, string, string), candidates are: //

Re: Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread Basile B. via Digitalmars-d-learn
On Monday, 4 December 2017 at 16:26:02 UTC, A Guy With a Question wrote: Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization... https://dlang.org/phobos/std_container_arra

Re: Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/4/17 11:26 AM, A Guy With a Question wrote: Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization... https://dlang.org/phobos/std_container_array.html I'm looking for

Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread A Guy With a Question via Digitalmars-d-learn
Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization... https://dlang.org/phobos/std_container_array.html I'm looking for something that doesn't have to resize every inser

Re: Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread A Guy With a Question via Digitalmars-d-learn
On Monday, 4 December 2017 at 16:26:02 UTC, A Guy With a Question wrote: Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization... https://dlang.org/phobos/std_container_arra

Re: std.container.array of struct inside a struct fails

2017-07-14 Thread drug via Digitalmars-d-learn
14.07.2017 19:53, Anton Fediushin пишет: On Friday, 14 July 2017 at 16:42:59 UTC, drug wrote: It's because Array(T) is a value type and needs type size to define itself, so you have expected forward reference. But T[] is reference type and its size is known in advance - it doesn't depend on type

Re: std.container.array of struct inside a struct fails

2017-07-14 Thread Anton Fediushin via Digitalmars-d-learn
On Friday, 14 July 2017 at 16:42:59 UTC, drug wrote: It's because Array(T) is a value type and needs type size to define itself, so you have expected forward reference. But T[] is reference type and its size is known in advance - it doesn't depend on type, it's always pointer.sizeof + length.si

Re: std.container.array of struct inside a struct fails

2017-07-14 Thread drug via Digitalmars-d-learn
14.07.2017 19:12, Anton Fediushin пишет: This code: - import std.container.array; struct Test { Array!Test t; } - Fails with an error: - /usr/include/dlang/dmd/std/traits.d(2404): Error: struct arrayissue.Test no size because of forward reference It's because Array(T)

std.container.array of struct inside a struct fails

2017-07-14 Thread Anton Fediushin via Digitalmars-d-learn
This code: - import std.container.array; struct Test { Array!Test t; } - Fails with an error: - /usr/include/dlang/dmd/std/traits.d(2404): Error: struct arrayissue.Test no size because of forward reference /usr/include/dlang/dmd/std/traits.d(3462): Error: template instance

Re: Using filter with std.container.Array.

2017-03-22 Thread Soulsbane via Digitalmars-d-learn
On Thursday, 23 March 2017 at 03:02:54 UTC, Jonathan M Davis wrote: On Thursday, March 23, 2017 02:53:40 Soulsbane via Digitalmars-d-learn wrote: [...] find just iterates to the first element that matches. It doesn't affect the range beyond that. It works basically the same way that find wou

Re: Using filter with std.container.Array.

2017-03-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 23, 2017 02:53:40 Soulsbane via Digitalmars-d-learn wrote: > Thanks for the reply Jonathan! Yes, I was trying to find all the > ids that match but couldn't get find to work. So I think I have > missed something somewhere. > > As a quick example: > import std.stdio; > import std.

Re: Using filter with std.container.Array.

2017-03-22 Thread Soulsbane via Digitalmars-d-learn
On Wednesday, 22 March 2017 at 07:30:48 UTC, Jonathan M Davis wrote: On Wednesday, March 22, 2017 07:06:47 Soulsbane via Digitalmars-d-learn wrote: Example code: struct Foo { string name; size_t id; } Array!Foo foo_; I get errors when I try to use filter like this: auto found = filter!(

Re: Using filter with std.container.Array.

2017-03-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 22, 2017 07:06:47 Soulsbane via Digitalmars-d-learn wrote: > Example code: > struct Foo > { >string name; >size_t id; > } > > Array!Foo foo_; > > I get errors when I try to use filter like this: > > auto found = filter!((Foo data, size_t id) => data.id == > id)(foo_[],

Using filter with std.container.Array.

2017-03-22 Thread Soulsbane via Digitalmars-d-learn
Example code: struct Foo { string name; size_t id; } Array!Foo foo_; I get errors when I try to use filter like this: auto found = filter!((Foo data, size_t id) => data.id == id)(foo_[], 100); I get this error source/app.d(15,62): Error: template std.algorithm.iteration.filter!(function

Re: Why does std.container.array does not work with foraech( i, a; array ) {} ?

2016-05-29 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 29 May 2016 at 09:07:07 UTC, Jonathan M Davis wrote: On Sunday, May 29, 2016 07:14:12 ParticlePeter via Digitalmars-d-learn wrote: Which of the op(Index) operators is responsible for enabling this kind of syntax? Would it be possible to get it work with UFCS or would I have to wrap

Re: Why does std.container.array does not work with foraech( i, a; array ) {} ?

2016-05-29 Thread Mithun Hunsur via Digitalmars-d-learn
On Sunday, 29 May 2016 at 09:07:07 UTC, Jonathan M Davis wrote: On Sunday, May 29, 2016 07:14:12 ParticlePeter via Digitalmars-d-learn wrote: [...] std.container.array.Array works with foreach via ranges. foreach(e; myContainer) { } gets lowered to foreach(e; myContainer[]) { } which in tu

Re: Why does std.container.array does not work with foraech( i, a; array ) {} ?

2016-05-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 29, 2016 07:14:12 ParticlePeter via Digitalmars-d-learn wrote: > Which of the op(Index) operators is responsible for enabling this > kind of syntax? > Would it be possible to get it work with UFCS or would I have to > wrap the array? std.container.array.Array works with foreach via

Why does std.container.array does not work with foraech( i, a; array ) {} ?

2016-05-29 Thread ParticlePeter via Digitalmars-d-learn
Which of the op(Index) operators is responsible for enabling this kind of syntax? Would it be possible to get it work with UFCS or would I have to wrap the array?

Re: Dense multidimensional std.container.array?

2016-01-26 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 18:07:40 UTC, ZombineDev wrote: [snip] Cool example.

Re: Dense multidimensional std.container.array?

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 14:55:53 UTC, Wilson wrote: Just wondering how to create a dense multidimensional array with the GC free array container? I don't want to use an array of arrays but I do want the array[0][0] notation. I suggest using std.experimental.ndslice [1] for multidimensio

Dense multidimensional std.container.array?

2016-01-26 Thread Wilson via Digitalmars-d-learn
Just wondering how to create a dense multidimensional array with the GC free array container? I don't want to use an array of arrays but I do want the array[0][0] notation.

Re: Pointer to std.container.Array data for C library

2015-08-28 Thread Oleg via Digitalmars-d-learn
On Friday, 28 August 2015 at 18:46:23 UTC, Oleg wrote: I found solution. I call length instead of reserve. It calls ensureInitialized and everything works fine. By default, Array won't initialize store. Oh, reserve calls it too. My mistake. I found the problem, that's because I passed an empt

Re: Pointer to std.container.Array data for C library

2015-08-28 Thread Oleg via Digitalmars-d-learn
std.container.Array like .ptr from an array? I need to pass a pointer to some C function (from DerelictGL3 binding) and avoid GC allocation. Thank you! I'm pretty sure you can just take the address of the first element, e.g. &a[0] or &a.front I've tried, it throws core.excepti

Re: Pointer to std.container.Array data for C library

2015-08-28 Thread John Colvin via Digitalmars-d-learn
On Friday, 28 August 2015 at 18:31:00 UTC, Oleg wrote: On Friday, 28 August 2015 at 18:21:04 UTC, John Colvin wrote: On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote: Hello! Is it possible to get pointer to a data in std.container.Array like .ptr from an array? I need to pass a pointer

Re: Pointer to std.container.Array data for C library

2015-08-28 Thread Oleg via Digitalmars-d-learn
On Friday, 28 August 2015 at 18:21:04 UTC, John Colvin wrote: On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote: Hello! Is it possible to get pointer to a data in std.container.Array like .ptr from an array? I need to pass a pointer to some C function (from DerelictGL3 binding) and avoid

Re: Pointer to std.container.Array data for C library

2015-08-28 Thread John Colvin via Digitalmars-d-learn
On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote: Hello! Is it possible to get pointer to a data in std.container.Array like .ptr from an array? I need to pass a pointer to some C function (from DerelictGL3 binding) and avoid GC allocation. Thank you! I'm pretty sure you can just

Pointer to std.container.Array data for C library

2015-08-28 Thread Oleg via Digitalmars-d-learn
Hello! Is it possible to get pointer to a data in std.container.Array like .ptr from an array? I need to pass a pointer to some C function (from DerelictGL3 binding) and avoid GC allocation. Thank you!

Re: std.container.array - are these arrays passed by reference?

2015-07-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 30, 2015 21:05:24 Harry P via Digitalmars-d-learn wrote: > I'm trying to avoid the gc so I'm using std.container.array > arrays instead of the standard ones. I know the standard arrays > return by reference so I imagine that the nogc alternative is > al

std.container.array - are these arrays passed by reference?

2015-07-30 Thread Harry P via Digitalmars-d-learn
I'm trying to avoid the gc so I'm using std.container.array arrays instead of the standard ones. I know the standard arrays return by reference so I imagine that the nogc alternative is also passed by reference because it'd be a struct with a pointer and a length, yeah? I jus

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:58:09 UTC, Kagamin wrote: (&arr.front())[0 .. arr.length] ? Yes, this works, nice, thanks :-)

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
don't see a way how I could access (cast) the raw data of a std.container.array to forward it to these wrapper functions. std.array(Range)(Range r) does a copy which I would like to avoid. Any advice ? Would this work? (&arr.front)[0 .. arr.length] Unfortunately not: Error: Vector!

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread Kagamin via Digitalmars-d-learn
(&arr.front())[0 .. arr.length] ?

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread via Digitalmars-d-learn
of a std.container.array to forward it to these wrapper functions. std.array(Range)(Range r) does a copy which I would like to avoid. Any advice ? Would this work? (&arr.front)[0 .. arr.length]

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
don't see a way how I could access (cast) the raw data of a std.container.array to forward it to these wrapper functions. std.array(Range)(Range r) does a copy which I would like to avoid. Any advice ? Try slicing it: `array[]` That gives me a range, which I could convert to an array

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread Alex Parrill via Digitalmars-d-learn
of a std.container.array to forward it to these wrapper functions. std.array(Range)(Range r) does a copy which I would like to avoid. Any advice ? Try slicing it: `array[]`

Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I don't see a way how I could access (cast) the raw data of a std.container.array to forward it to these wrapper functions. std.

Re: Printing an std.container.Array

2015-04-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/16/15 5:18 PM, Dennis Ritchie wrote: On Thursday, 16 April 2015 at 20:34:19 UTC, Steven Schveighoffer wrote: On 4/16/15 4:18 PM, Panke wrote: Yep, but problem is almost no one expect this, or know this. We definitely should do better. How? By doing what is expected. Print the array co

Re: Printing an std.container.Array

2015-04-17 Thread Bayan Rafeh via Digitalmars-d-learn
On Thursday, 16 April 2015 at 20:08:30 UTC, H. S. Teoh wrote: On Thu, Apr 16, 2015 at 07:55:52PM +, Bayan Rafeh via Digitalmars-d-learn wrote: Executing this code: import std.container.array; import std.stdio; int main() { writeln(Array!int([1, 2])); return 0; } outputs

Re: Printing an std.container.Array

2015-04-16 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Apr 2015 20:18:40 + Panke via Digitalmars-d-learn wrote: > > > > Yep, but problem is almost no one expect this, or know this. We > > definitely > > should do better. > > How? Improve doc at least. But it would be fine to have something like dump function (equivalent of php var_

Re: Printing an std.container.Array

2015-04-16 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 16 April 2015 at 20:34:19 UTC, Steven Schveighoffer wrote: On 4/16/15 4:18 PM, Panke wrote: Yep, but problem is almost no one expect this, or know this. We definitely should do better. How? By doing what is expected. Print the array contents. See my new comment in that PR.

Re: Printing an std.container.Array

2015-04-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/16/15 4:18 PM, Panke wrote: Yep, but problem is almost no one expect this, or know this. We definitely should do better. How? By doing what is expected. Print the array contents. See my new comment in that PR. -Steve

Re: Printing an std.container.Array

2015-04-16 Thread Panke via Digitalmars-d-learn
Yep, but problem is almost no one expect this, or know this. We definitely should do better. How?

Re: Printing an std.container.Array

2015-04-16 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, 16 Apr 2015 13:05:48 -0700 "H. S. Teoh via Digitalmars-d-learn" wrote: > On Thu, Apr 16, 2015 at 07:55:52PM +, Bayan Rafeh via Digitalmars-d-learn > wrote: > > Executing this code: > > > > import std.container.array; > > import std.stdio; &g

Re: Printing an std.container.Array

2015-04-16 Thread Panke via Digitalmars-d-learn
On Thursday, 16 April 2015 at 19:55:53 UTC, Bayan Rafeh wrote: How am I supposed to interpret this? The array contains two elements. The first equals one and the second equals two. What happens under the hood is that Array does no provide a toString method, instead a default is used. This

Re: Printing an std.container.Array

2015-04-16 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Apr 16, 2015 at 07:55:52PM +, Bayan Rafeh via Digitalmars-d-learn wrote: > Executing this code: > > import std.container.array; > import std.stdio; > > > int main() { > writeln(Array!int([1, 2])); > return 0; > } > > outputs the

Re: Printing an std.container.Array

2015-04-16 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, 16 Apr 2015 19:55:52 + Bayan Rafeh via Digitalmars-d-learn wrote: > Executing this code: > > import std.container.array; > import std.stdio; > > > int main() { > writeln(Array!int([1, 2])); > return 0; > } > > outputs the following

Printing an std.container.Array

2015-04-16 Thread Bayan Rafeh via Digitalmars-d-learn
Executing this code: import std.container.array; import std.stdio; int main() { writeln(Array!int([1, 2])); return 0; } outputs the following: Array!int(RefCounted!(Payload, cast(RefCountedAutoInitialize)0)(RefCountedStore(B694B0))) The strange thing is that this works fine

Re: Error instantiating std.container.Array

2015-03-02 Thread Ali Çehreli via Digitalmars-d-learn
was wrong. http://dpaste.dzfl.pl/16d202b7124d Wow, I honestly could have NEVER foreseen this. This is all it takes for a class being unusable in a std.container.Array class MyClass { void init(); } Existing issue: https://issues.dlang.org/show_bug.cgi?id=12545 Ali

Re: Error instantiating std.container.Array

2015-03-02 Thread Tobias Pankrath via Digitalmars-d-learn
ally found what was wrong. http://dpaste.dzfl.pl/16d202b7124d Wow, I honestly could have NEVER foreseen this. This is all it takes for a class being unusable in a std.container.Array class MyClass { void init(); } .init is a special property of every type: http://dlang.org/property.html#init

Re: Error instantiating std.container.Array

2015-03-02 Thread Francesco Cattoglio via Digitalmars-d-learn
I honestly could have NEVER foreseen this. This is all it takes for a class being unusable in a std.container.Array class MyClass { void init(); }

Re: Error instantiating std.container.Array

2015-03-02 Thread Tobias Pankrath via Digitalmars-d-learn
I'm really clueless... :P Something is wrong with your Material class, but you'll need to show us a reduced example.

Re: Error instantiating std.container.Array

2015-03-02 Thread Francesco Cattoglio via Digitalmars-d-learn
On Monday, 2 March 2015 at 14:46:31 UTC, ketmar wrote: On Mon, 02 Mar 2015 14:40:50 +, Francesco Cattoglio wrote: did you tried to dustmite[1] it? [1] https://github.com/CyberShadow/DustMite/wiki I tried to "dub dustmite", but it failed with a "object.Exception@DustMite\dustmite.d(220):

Re: Error instantiating std.container.Array

2015-03-02 Thread ketmar via Digitalmars-d-learn
On Mon, 02 Mar 2015 14:40:50 +, Francesco Cattoglio wrote: did you tried to dustmite[1] it? [1] https://github.com/CyberShadow/DustMite/wiki signature.asc Description: PGP signature

Re: Error instantiating std.container.Array

2015-03-02 Thread Francesco Cattoglio via Digitalmars-d-learn
On Monday, 2 March 2015 at 14:14:19 UTC, Tobias Pankrath wrote: Try to reduce your Material class for a small failing example. It's probably your constructors or opAssign or something like that. Anyway, it's a bug if template errors from the implementation bubble up, so please file a report. I

Re: Error instantiating std.container.Array

2015-03-02 Thread Tobias Pankrath via Digitalmars-d-learn
On Monday, 2 March 2015 at 14:08:29 UTC, Francesco Cattoglio wrote: I'm trying to instantiate a std.container.Array of a given class (named Material), by a simple Array!Material _myStuff; I get two compile errors stating the following: C:\D\dmd2\windows\bin\..\..\src\phobos\std\cont

Error instantiating std.container.Array

2015-03-02 Thread Francesco Cattoglio via Digitalmars-d-learn
I'm trying to instantiate a std.container.Array of a given class (named Material), by a simple Array!Material _myStuff; I get two compile errors stating the following: C:\D\dmd2\windows\bin\..\..\src\phobos\std\container\array.d(85): Error: template std.algorithm.initializeAll cannot d

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 24, 2015 13:11:31 Nordlöw via Digitalmars-d-learn wrote: > Is there a reason why std.container.Array have to be explicitly > sliced before being processed by range algorithms such as filter > typically as > > import std.container: Array; > Array!int

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread Nordlöw
On Saturday, 24 January 2015 at 21:10:29 UTC, ketmar wrote: yes. the following source produces the same machine code regardless of slicing on `z` with 'dmd -c': Nice, that's what I had hoped for! Thanks.

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread ketmar via Digitalmars-d-learn
On Sat, 24 Jan 2015 19:51:30 +, Nordlöw wrote: > On Saturday, 24 January 2015 at 13:59:13 UTC, Tobias Pankrath wrote: >>>foreach (e; a[].filter!"true") {} > > Is a[] a no-op if a is a D normal builtin array/slice? yes. the following source produces the same machine code regardless of s

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread Nordlöw
On Saturday, 24 January 2015 at 13:59:13 UTC, Tobias Pankrath wrote: foreach (e; a[].filter!"true") {} Is a[] a no-op if a is a D normal builtin array/slice?

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread Nordlöw
On Saturday, 24 January 2015 at 15:30:36 UTC, Laeeth Isharc wrote: One thing to mention in the revised docs in the introduction to std.algorithms. https://github.com/D-Programming-Language/phobos/pull/2904 Thanks!

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 24 January 2015 at 13:11:33 UTC, Nordlöw wrote: Is there a reason why std.container.Array have to be explicitly sliced before being processed by range algorithms such as filter typically as import std.container: Array; Array!int a; foreach (e; a[].filter!"

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 24 January 2015 at 13:11:33 UTC, Nordlöw wrote: Is there a reason why std.container.Array have to be explicitly sliced before being processed by range algorithms such as filter typically as import std.container: Array; Array!int a; foreach (e; a[].filter!"

Explicit Slicing of std.container.Array

2015-01-24 Thread Nordlöw
Is there a reason why std.container.Array have to be explicitly sliced before being processed by range algorithms such as filter typically as import std.container: Array; Array!int a; foreach (e; a[].filter!"true") {} ? Does memory allocation play a role? I would like

Re: std.container.Array deep-copy?

2014-10-10 Thread qznc via Digitalmars-d-learn
On Friday, 10 October 2014 at 10:59:59 UTC, Sag Academy wrote: On Friday, 10 October 2014 at 10:32:17 UTC, yazd wrote: Like the following? That did not work. Array!Foo y = Array!Foo(x[]); How does it not work? It compiles successfully: http://dpaste.dzfl.pl/583d20e426a0 yeah man. You are

Re: std.container.Array deep-copy?

2014-10-10 Thread Sag Academy via Digitalmars-d-learn
On Friday, 10 October 2014 at 10:32:17 UTC, yazd wrote: Like the following? That did not work. Array!Foo y = Array!Foo(x[]); How does it not work? It compiles successfully: http://dpaste.dzfl.pl/583d20e426a0 yeah man.

Re: std.container.Array deep-copy?

2014-10-10 Thread yazd via Digitalmars-d-learn
Like the following? That did not work. Array!Foo y = Array!Foo(x[]); How does it not work? It compiles successfully: http://dpaste.dzfl.pl/583d20e426a0

Re: std.container.Array deep-copy?

2014-10-10 Thread qznc via Digitalmars-d-learn
On Friday, 10 October 2014 at 06:27:35 UTC, yazd wrote: On Thursday, 9 October 2014 at 21:24:55 UTC, qznc wrote: On Thursday, 9 October 2014 at 21:14:46 UTC, qznc wrote: How can you deep-copy a std.container.Array instance? Ok, the deep-copy problem already got resolved on reddit: Use dup

Re: std.container.Array deep-copy?

2014-10-09 Thread yazd via Digitalmars-d-learn
On Thursday, 9 October 2014 at 21:24:55 UTC, qznc wrote: On Thursday, 9 October 2014 at 21:14:46 UTC, qznc wrote: How can you deep-copy a std.container.Array instance? Ok, the deep-copy problem already got resolved on reddit: Use dup. However, the error is still open. You cannot give an

Re: std.container.Array deep-copy?

2014-10-09 Thread qznc via Digitalmars-d-learn
On Thursday, 9 October 2014 at 21:14:46 UTC, qznc wrote: How can you deep-copy a std.container.Array instance? Ok, the deep-copy problem already got resolved on reddit: Use dup. However, the error is still open. You cannot give an Array!X argument to constructor/replace/insertBefore of Array

std.container.Array deep-copy?

2014-10-09 Thread qznc via Digitalmars-d-learn
How can you deep-copy a std.container.Array instance? The actual array data is heap-allocated and reference-counted. Assignment and .dup only create additional references. Using a copy constructor yields an error: Array!Foo x; Array!Foo y = Array!Foo(x); Error: template std.container.Array

Re: isArray and std.container.Array

2014-10-04 Thread Nordlöw
On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: I realized that this is the reason why msgpack doesn't correctly pack std.container.Array. I've added support for std.container.Array in msgpack-d by hand at https://github.com/nordlow/msgpack-d/commits/container-support

Re: isArray and std.container.Array

2014-09-29 Thread monarch_dodra via Digitalmars-d-learn
:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of http://forum.dlang.org/thread/aclapseyptgcwntda...@forum.dlang.org#post-aclapseyptgcwntdavwt:40forum.dlang.org I realized

Re: isArray and std.container.Array

2014-09-29 Thread via Digitalmars-d-learn
x27;t match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of http://forum.dlang.org/thread/aclapseyptgcwntda...@forum.dlang.org#post-aclapseyptgcwntdavwt:40forum.dlang.org I realized that this is the reason why msgpack doesn't

Re: isArray and std.container.Array

2014-09-28 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:06:09 UTC, Marc Schütz wrote: On Sunday, 28 September 2014 at 16:12:53 UTC, Meta wrote: On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking bec

Re: isArray and std.container.Array

2014-09-28 Thread via Digitalmars-d-learn
On Sunday, 28 September 2014 at 16:12:53 UTC, Meta wrote: On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of http://forum.dlang.

Re: isArray and std.container.Array

2014-09-28 Thread Meta via Digitalmars-d-learn
On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of http://forum.dlang.org/thread/aclapseyptgcwntda...@forum.dlang.org#post-aclapseypt

Re: std.container.Array support in msgpack

2014-09-28 Thread Nordlöw
On Saturday, 27 September 2014 at 21:24:14 UTC, Nordlöw wrote: How do I add the leading byte 146? Update: This is achieved by calling stream_.put() which is only allowed in members of PackerImpl.

isArray and std.container.Array

2014-09-28 Thread Nordlöw
Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after looking into msgpack-d because of http://forum.dlang.org/thread/aclapseyptgcwntda...@forum.dlang.org#post-aclapseyptgcwntdavwt:40forum.dlang.org I realized that this is the

std.container.Array support in msgpack

2014-09-27 Thread Nordlöw
I'm trying to figure out how to add raw bytes the packed stream in msgpack-d. My current try is import std.stdio; import std.conv: to; import std.container: Array; import msgpack; static void stringArrayPackHandler(E)(ref Packer p, ref Array!E x) { // p

Re: std.container.array linker error on OS X

2014-09-09 Thread Etienne via Digitalmars-d-learn
On 2014-09-09 3:58 PM, Etienne wrote: I have to specify that AsyncSignal is defined as a "final shared class", and the array is defined as a Array!AsyncSignal I'm not sure if the compiler on OSX could act different and add the shared symbols there? Meh, I answered my own question. Substituting

Re: std.container.array linker error on OS X

2014-09-09 Thread Etienne via Digitalmars-d-learn
On 2014-09-09 4:11 PM, Etienne wrote: On 2014-09-09 3:58 PM, Etienne wrote: I have to specify that AsyncSignal is defined as a "final shared class", and the array is defined as a Array!AsyncSignal I'm not sure if the compiler on OSX could act different and add the shared symbols there? Meh, I

  1   2   >