Re: More IndexedBy

2015-02-22 Thread Nordlöw
On Sunday, 22 February 2015 at 10:54:10 UTC, Nordlöw wrote: I got things working better (without alias this in Index) at https://github.com/nordlow/justd/blob/a3b0df924fd774709ab7844e6c47b5a8e5ff3917/typecons_ex.d than with my previous solution (with alias this in Index) at

opCast and std.conv.to

2015-02-22 Thread via Digitalmars-d-learn
I tried to override the opCast operator in a class to be able to explicitly convert the class to a string, but to!string just returns the name of the class. Do opCast and to! together not work with strings and does that mean that i have to use alias this?

Re: opCast and std.conv.to

2015-02-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 22 February 2015 at 13:04:56 UTC, Jacques Müller wrote: I tried to override the opCast operator in a class to be able to explicitly convert the class to a string, but to!string just returns the name of the class. to!string actually forwards to a special function, string toString()

Re: opCast and std.conv.to

2015-02-22 Thread via Digitalmars-d-learn
On Sunday, 22 February 2015 at 13:15:31 UTC, Adam D. Ruppe wrote: to!string actually forwards to a special function, string toString() {} which you'll need to implement and override from the base class. Thanks, that's good to know. I was just wondering why my code wasn't working correctly.

Searching for Elements in Containers

2015-02-22 Thread Nordlöw
Is there some function similar to std.algorithm.find() which returns an element index instead of a range? I guess 0 means no hit and 1, 2, 3 means hits at indexes 0, 1, 2 etc. I want this to avoid having to create ranges ([]) when searching for a specific element in std.container.Array.

More IndexedBy

2015-02-22 Thread Nordlöw
At https://github.com/nordlow/justd/blob/master/typecons_ex.d#L93 I'm trying to implement a wrapper type that provides type-safe indexing and slicing via an integer-like wrapper type I call *Index*. However there's something wrong implicit conversions because assert(jx[J(0)] == 11);

Re: More IndexedBy

2015-02-22 Thread Nordlöw
On Sunday, 22 February 2015 at 10:52:26 UTC, Nordlöw wrote: At https://github.com/nordlow/justd/blob/master/typecons_ex.d#L93 I'm trying to implement a wrapper type that provides type-safe indexing and slicing via an integer-like wrapper type I call Here's a copy of the definitions for

Re: Best practices for reading public interfaces

2015-02-22 Thread MrSmith via Digitalmars-d-learn
On Saturday, 21 February 2015 at 20:46:09 UTC, Kenny wrote: I like D modules and it's a major point in the list of major points why I like D (there is also the second not so nice wft-list but it's for another post). I'm annoyed with C++ includes and I'm tired to create 2 files every time when I

Re: Searching for Elements in Containers

2015-02-22 Thread Tobias Pankrath via Digitalmars-d-learn
On Sunday, 22 February 2015 at 13:53:51 UTC, Nordlöw wrote: Is there some function similar to std.algorithm.find() which returns an element index instead of a range? I guess 0 means no hit and 1, 2, 3 means hits at indexes 0, 1, 2 etc. I want this to avoid having to create ranges ([]) when

Passing variadic arguments to C

2015-02-22 Thread Foo via Digitalmars-d-learn
Is this possible? Example: void foo(Args...)(auto ref Args args) { sprintf(str.ptr, fmt.ptr, args); }

Re: Passing variadic arguments to C

2015-02-22 Thread anonymous via Digitalmars-d-learn
On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote: Is this possible? Example: void foo(Args...)(auto ref Args args) { sprintf(str.ptr, fmt.ptr, args); } yes

Re: Passing variadic arguments to C

2015-02-22 Thread Foo via Digitalmars-d-learn
On Sunday, 22 February 2015 at 17:20:23 UTC, Foo wrote: On Sunday, 22 February 2015 at 17:15:06 UTC, anonymous wrote: On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote: Is this possible? Example: void foo(Args...)(auto ref Args args) { sprintf(str.ptr, fmt.ptr, args); } yes

Re: Passing variadic arguments to C

2015-02-22 Thread Foo via Digitalmars-d-learn
On Sunday, 22 February 2015 at 17:15:06 UTC, anonymous wrote: On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote: Is this possible? Example: void foo(Args...)(auto ref Args args) { sprintf(str.ptr, fmt.ptr, args); } yes I get the error, that I cannot pass a dynamic array

Re: Best practices for reading public interfaces

2015-02-22 Thread Kenny via Digitalmars-d-learn
On Sunday, 22 February 2015 at 12:13:02 UTC, MrSmith wrote: You can also fold all the function bodies in your editor, this helps me to read massive sources. Oh, I almost forgot about this feature, never used it in C++ but for D it looks promising. Thanks!

Re: Best practices for reading public interfaces

2015-02-22 Thread Kenny via Digitalmars-d-learn
On Saturday, 21 February 2015 at 20:56:26 UTC, anonymous wrote: On Saturday, 21 February 2015 at 20:46:09 UTC, Kenny wrote: b) Write DDocs and read documentation. The problem here is that I'm going to use D only for my own projects and in the last time I tend to write less documentation, for

Re: Best practices for reading public interfaces

2015-02-22 Thread ketmar via Digitalmars-d-learn
On Sun, 22 Feb 2015 16:12:49 +, Kenny wrote: On Saturday, 21 February 2015 at 20:56:26 UTC, anonymous wrote: On Saturday, 21 February 2015 at 20:46:09 UTC, Kenny wrote: b) Write DDocs and read documentation. The problem here is that I'm going to use D only for my own projects and in the

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread Martin Nowak via Digitalmars-d-learn
On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works. You should use shared static this to initialize immutable variables.

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread stewarth via Digitalmars-d-learn
On Monday, 23 February 2015 at 04:04:08 UTC, ketmar wrote: On Mon, 23 Feb 2015 02:15:08 +, stewarth wrote: On Monday, 23 February 2015 at 02:10:09 UTC, amber wrote: On Sunday, 22 February 2015 at 23:17:33 UTC, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread Ali Çehreli via Digitalmars-d-learn
On 02/22/2015 03:17 PM, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works. You should use shared static this to initialize immutable variables. Is that because they are not thread-local? If so, initializing

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread amber via Digitalmars-d-learn
On Sunday, 22 February 2015 at 23:17:33 UTC, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works. You should use shared static this to initialize immutable variables. OK, thanks a lot for the help. Cheers,

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread ketmar via Digitalmars-d-learn
On Mon, 23 Feb 2015 02:15:08 +, stewarth wrote: On Monday, 23 February 2015 at 02:10:09 UTC, amber wrote: On Sunday, 22 February 2015 at 23:17:33 UTC, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works.

Re: vibe-d basic build errors

2015-02-22 Thread Charles via Digitalmars-d-learn
On Friday, 20 February 2015 at 14:36:47 UTC, MartinNowak wrote: On Friday, 20 February 2015 at 04:48:09 UTC, Charles wrote: They're installer versions, dub is 0.9.22 Nov 22 I want to say, and DMD is 2.066.1 Same ones I tried. With --force dmd seems to fail but there is not output. Can you

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread stewarth via Digitalmars-d-learn
On Monday, 23 February 2015 at 02:10:09 UTC, amber wrote: On Sunday, 22 February 2015 at 23:17:33 UTC, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works. You should use shared static this to initialize