Get template parameter value

2015-09-29 Thread rumbu via Digitalmars-d-learn
Having a template: struct SomeStruct(int size) { } Is there any language trait returning the value of size template parameter for the template instantiation SomeStruct!10? In fact, I'm interested in an eponymous template to test if some type is a template inttantation for SomeStruct(int

Re: enum to flags

2015-09-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 06:08:03 UTC, Cauterite wrote: On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? You

Re: enum to flags

2015-09-29 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? You could cheat with operator overloading: enum blah {

Re: enum to flags

2015-09-29 Thread Meta via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? use like: enum blah { foo, bar, baz, } alias blahFlags =

Re: enum to flags

2015-09-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:18:52 UTC, John Colvin wrote: On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? use

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-29 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:15:29 UTC, ponce wrote: On Monday, 28 September 2015 at 16:01:54 UTC, Sebastiaan Koppe wrote: I could not find out which redistributable I had to install (what version of VS did you have installed / on what version of windows are you?). I decided to install

Re: Get template parameter value

2015-09-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:53:39 UTC, Kagamin wrote: On Tuesday, 29 September 2015 at 09:11:15 UTC, John Colvin wrote: Welcome to the weird and wonderful work of http://dlang.org/expression.html#IsExpression No, use template pattern matching instead: struct A(int s){} template

Re: Get template parameter value

2015-09-29 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 07:50:42 UTC, rumbu wrote: Having a template: struct SomeStruct(int size) { } Is there any language trait returning the value of size template parameter for the template instantiation SomeStruct!10? Something like this is ok? struct SomeStruct(int size) {

Re: enum to flags

2015-09-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? use like: enum blah { foo, bar, baz, } alias blahFlags =

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-29 Thread ponce via Digitalmars-d-learn
On Monday, 28 September 2015 at 16:01:54 UTC, Sebastiaan Koppe wrote: I could not find out which redistributable I had to install (what version of VS did you have installed / on what version of windows are you?). I decided to install them all, but couldn't install the one for 2015 (due to

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-29 Thread Kagamin via Digitalmars-d-learn
On Monday, 28 September 2015 at 16:36:47 UTC, ponce wrote: OK, but why does that need to happen? I don't get why does linking with MS linker implies a runtime dependency. I thought we would be left out of these sort of problems when using D :( About universal CRT:

Re: Get template parameter value

2015-09-29 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 08:44:03 UTC, Andrea Fontana wrote: On Tuesday, 29 September 2015 at 07:50:42 UTC, rumbu wrote: Having a template: struct SomeStruct(int size) { } Is there any language trait returning the value of size template parameter for the template instantiation

Re: Get template parameter value

2015-09-29 Thread rumbu via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:53:39 UTC, Kagamin wrote: On Tuesday, 29 September 2015 at 09:11:15 UTC, John Colvin wrote: Welcome to the weird and wonderful work of http://dlang.org/expression.html#IsExpression No, use template pattern matching instead: struct A(int s){} template

Re: Get template parameter value

2015-09-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 07:50:42 UTC, rumbu wrote: Having a template: struct SomeStruct(int size) { } Is there any language trait returning the value of size template parameter for the template instantiation SomeStruct!10? This should do it (untested): template SomeStructSize(T)

Re: Threading Questions

2015-09-29 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-09-29 at 03:05 +, bitwise via Digitalmars-d-learn wrote: > On Monday, 28 September 2015 at 11:47:38 UTC, Russel Winder wrote: > > I hadn't answered as I do not have answers to the questions you > > ask. My reason: people should not be doing their codes using > > these low-level

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-29 Thread ponce via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:44:58 UTC, Sebastiaan Koppe wrote: On Tuesday, 29 September 2015 at 09:15:29 UTC, ponce wrote: On Monday, 28 September 2015 at 16:01:54 UTC, Sebastiaan Koppe wrote: I could not find out which redistributable I had to install (what version of VS did you have

Re: Why getting private member fails using getMember trait in a template?

2015-09-29 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 26 September 2015 at 10:10:39 UTC, Alexandru Ermicioi wrote: Suppose we have, two modules: module testOne; [...] So, is this behavior correct? If yes, then why?

Re: Get template parameter value

2015-09-29 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:11:15 UTC, John Colvin wrote: Welcome to the weird and wonderful work of http://dlang.org/expression.html#IsExpression No, use template pattern matching instead: struct A(int s){} template B(T:A!s, int s){ enum B=s; } static assert(B!(A!4)==4);

Move Semantics

2015-09-29 Thread Alex via Digitalmars-d-learn
Another question on move semantics from the cheap seats... See my code here: http://dpaste.dzfl.pl/995c5af59dd6 There are indeed three questions, all marked in the code, so the rest of the text here is maybe redundant... but just in case and for summary: I try to model a inner class of some

Re: Get template parameter value

2015-09-29 Thread Artur Skawina via Digitalmars-d-learn
On 09/29/15 12:13, rumbu via Digitalmars-d-learn wrote: > On Tuesday, 29 September 2015 at 09:53:39 UTC, Kagamin wrote: >> On Tuesday, 29 September 2015 at 09:11:15 UTC, John Colvin wrote: >>> Welcome to the weird and wonderful work of >>> http://dlang.org/expression.html#IsExpression >> >> No,

Re: Interval Arithmetic

2015-09-29 Thread anonymous via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 21:04:06 UTC, Wulfrick wrote: Is there an interval arithmetic library in D? I couldn’t find one. None I am aware of. In case I had to write my own, I understand that the IEEE standard floating point arithmetic provides operations for rounding up or down

Re: Threading Questions

2015-09-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/29/15 4:38 PM, Johannes Pfau wrote: Am Tue, 29 Sep 2015 15:10:58 -0400 schrieb Steven Schveighoffer : 3) Why do I have to pass a "Mutex" to "Condition"? Why can't I just pass an "Object"? An object that implements the Monitor interface may not actually be a mutex.

Re: Move Semantics

2015-09-29 Thread Alex via Digitalmars-d-learn
Thank you very much for the comments. It is much clearer now. The .outer link is just a shortcut, which does not mean I don't have to reset it, where I have to. So... essentially, my expectation WAS to subjective and I have to separate better, what is the part of the model in my head and what

Re: Threading Questions

2015-09-29 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 29 Sep 2015 15:10:58 -0400 schrieb Steven Schveighoffer : > > > 3) Why do I have to pass a "Mutex" to "Condition"? Why can't I just > > pass an "Object"? > > An object that implements the Monitor interface may not actually be a > mutex. For example, a

Interval Arithmetic

2015-09-29 Thread Wulfrick via Digitalmars-d-learn
Is there an interval arithmetic library in D? I couldn’t find one. In case I had to write my own, I understand that the IEEE standard floating point arithmetic provides operations for rounding up or down certain operations like summing, subtracting, etc. (thus overriding the default behavior

Re: Move Semantics

2015-09-29 Thread anonymous via Digitalmars-d-learn
On Tuesday 29 September 2015 16:38, Alex wrote: > Another question on move semantics from the cheap seats... > > See my code here: http://dpaste.dzfl.pl/995c5af59dd6 [...] > The first (minor) question is: > I have to initialize some dummy inner objects, before I can apply > the move action. Is

Re: Move Semantics

2015-09-29 Thread Ali Çehreli via Digitalmars-d-learn
On 09/29/2015 07:38 AM, Alex wrote: > See my code here: http://dpaste.dzfl.pl/995c5af59dd6 > Following my code, the inner object I moved does not disappear from the > array in the source outer object. Why? > After I moved the inner object to the new outer object, the pointer to > the outer

Re: Threading Questions

2015-09-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/15 11:19 AM, bitwise wrote: Hey, I've got a few questions if anybody's got a minute. I'm trying to wrap my head around the threading situation in D. So far, things seem to be working as expected, but I want to verify my solutions. 1) Are the following two snippets exactly