Re: write a function template specialisation that tests if an argument is known at compile time

2018-08-13 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 02:53:01 UTC, Cecil Ward wrote: On Sunday, 12 August 2018 at 12:27:59 UTC, Alex wrote: On Saturday, 11 August 2018 at 05:17:51 UTC, Cecil Ward wrote: T myfunc(T)( T x, uint mask ) if ( mask == 3 ) { return fast_func( x, mask ); } [...] Is it the volc

Re: write a function template specialisation that tests if an argument is known at compile time

2018-08-13 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 12 August 2018 at 12:27:59 UTC, Alex wrote: On Saturday, 11 August 2018 at 05:17:51 UTC, Cecil Ward wrote: T myfunc(T)( T x, uint mask ) if ( mask == 3 ) { return fast_func( x, mask ); } [...] Is it the volcano pattern you are looking for? https://p0nce.github.io/d-idio

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:14:56 AM MDT Andrey via Digitalmars-d-learn wrote: > On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: > > Unsupported. AA's don't go between CT and RT. You must use a > > module constructor to initialize it. > > Will be supported in future? Maybe, bu

Re: string to char conv

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:42:02 PM MDT zeus via Digitalmars-d-learn wrote: > On Tuesday, 14 August 2018 at 00:24:53 UTC, Jonathan M Davis > > wrote: > > On Monday, August 13, 2018 6:06:22 PM MDT zeus via > > > > Digitalmars-d-learn wrote: > >> [...] > > > > Why are you casting the string to a c

Re: string to char conv

2018-08-13 Thread zeus via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 00:24:53 UTC, Jonathan M Davis wrote: On Monday, August 13, 2018 6:06:22 PM MDT zeus via Digitalmars-d-learn wrote: [...] Why are you casting the string to a char*? That's just going to make writeln print out the pointer value. If you want to print out the value

Re: string to char conv

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:24:53 PM MDT Jonathan M Davis via Digitalmars- d-learn wrote: > On Monday, August 13, 2018 6:06:22 PM MDT zeus via Digitalmars-d-learn > > wrote: > > i have the following code in d and i get as result 4D77EB, also i > > have the following code in c++ wich give me as res

Re: string to char conv

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:06:22 PM MDT zeus via Digitalmars-d-learn wrote: > i have the following code in d and i get as result 4D77EB, also i > have the following code in c++ wich give me as results > 0xABCDEF123abcdef12345678909832190 how i can get in d > 0xABCDEF123abcdef12345678

string to char conv

2018-08-13 Thread zeus via Digitalmars-d-learn
i have the following code in d and i get as result 4D77EB, also i have the following code in c++ wich give me as results 0xABCDEF123abcdef12345678909832190 how i can get in d 0xABCDEF123abcdef12345678909832190 instead of 4D77EB // D void test(string test){ cha

Re: unimplemented abstract function compiles.

2018-08-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-08-12 19:29, Eric wrote: I thought it would work the same way as an interface (which must be implemented by the direct sub class, otherwise compile error). But apparently it's possible to implement an abstract function anywhere in the class hierarchy. That makes it, in this case, impossi

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Timoses via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:21:45 UTC, Andrey wrote: On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() { Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: "It's Two...", Test.Type.Th

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Seb via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:21:45 UTC, Andrey wrote: On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() { Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: "It's Two...", Test.Type.Th

Re: Importing struct

2018-08-13 Thread Timoses via Digitalmars-d-learn
On Monday, 13 August 2018 at 14:16:47 UTC, Mike Parker wrote: On Monday, 13 August 2018 at 13:09:24 UTC, Andrey wrote: On Monday, 13 August 2018 at 13:05:28 UTC, evilrat wrote: however the best option is simply avoid naming anything with same name as module. Hmm, I thought that name of class

Re: Importing struct

2018-08-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:09:24 UTC, Andrey wrote: On Monday, 13 August 2018 at 13:05:28 UTC, evilrat wrote: however the best option is simply avoid naming anything with same name as module. Hmm, I thought that name of class should match name of file... And how to name a file that conta

Re: Importing struct

2018-08-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:09:24 UTC, Andrey wrote: On Monday, 13 August 2018 at 13:05:28 UTC, evilrat wrote: however the best option is simply avoid naming anything with same name as module. Hmm, I thought that name of class should match name of file... And how to name a file that conta

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Andrey via Digitalmars-d-learn
On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: You must use a module constructor to initialize it. Tried this: static this() { Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: "It's Two...", Test.Type.Three: "And... Three!"]; } struct Test { // ... } I h

Re: InputRange help: (1) repeated dtor calls and (2) managing resources needing free()

2018-08-13 Thread Seb via Digitalmars-d-learn
On Monday, 13 August 2018 at 04:23:49 UTC, James Blachly wrote: On Thursday, 14 June 2018 at 00:42:25 UTC, James Blachly wrote: ... I assume the (apparent) lack of parity between ctor and dtor is because the "default postblit" (which I figured out for a struct means an empty `this(this)` ctor)

Re: Importing struct

2018-08-13 Thread Andrey via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:05:28 UTC, evilrat wrote: however the best option is simply avoid naming anything with same name as module. Hmm, I thought that name of class should match name of file... And how to name a file that contains only one class/struct? Like in my case. What usually

Re: Importing struct

2018-08-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 August 2018 at 12:44:44 UTC, evilrat wrote: Another option to save up on typing is renamed imports import mc = MyClass; mc.MyClass.parse(...) this also should work import mc = MyClass; alias MyClass = mc.MyClass; // make synonym // now it is just MyClass MyClas

Re: Importing struct

2018-08-13 Thread evilrat via Digitalmars-d-learn
On Monday, 13 August 2018 at 12:34:25 UTC, Andrey wrote: Hello, This is my test project: source/app.d source/MyClass.d app.d: import std.stdio; import MyClass; void main(string[] args) { MyClass.MyClass.parse(args); // I want just MyClass.p

Importing struct

2018-08-13 Thread Andrey via Digitalmars-d-learn
Hello, This is my test project: source/app.d source/MyClass.d app.d: import std.stdio; import MyClass; void main(string[] args) { MyClass.MyClass.parse(args); // I want just MyClass.parse(args); } ---

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Andrey via Digitalmars-d-learn
On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: Unsupported. AA's don't go between CT and RT. You must use a module constructor to initialize it. Will be supported in future?

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread rikki cattermole via Digitalmars-d-learn
On 13/08/2018 11:38 PM, Andrey wrote: Hello, I need to declare a static compile-time assoc array inside struct:     struct Test     {     enum Type : ubyte     {     One,     Two,     Three     }     static immutable string[Type] DESCRIPTION = [Ty

How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Andrey via Digitalmars-d-learn
Hello, I need to declare a static compile-time assoc array inside struct: struct Test { enum Type : ubyte { One, Two, Three } static immutable string[Type] DESCRIPTION = [Type.One: "One!", Type.Two: "It's Two...", Type.T