Re: Accessing __FILE__ and __LINE__ of caller in combination with varargs?

2016-04-16 Thread Simen Kjaeraas via Digitalmars-d-learn
On Saturday, 16 April 2016 at 00:03:59 UTC, Jonathan M Davis wrote: On Friday, April 15, 2016 20:52:42 WebFreak001 via Digitalmars-d-learn wrote: void assertf(string file = __FILE__, size_t line = __LINE__, Args...)(lazy bool condition, in string message, Args args) { Yes, you can do that, b

Re: infer type argument in classe constructor?

2016-03-29 Thread Simen Kjaeraas via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 10:13:28 UTC, Puming wrote: Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main() { Message[] src = ...; auto decoder = new Decoder!(Message[

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread Simen Kjaeraas via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 18:10:05 UTC, ParticlePeter wrote: Thanks Simen, your tokenCounter is inspirational, for the rest I'll take some time for testing. My pleasure. :) Testing it on your example data shows it to work there. However, as stated above, the documentation says it's unde

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread Simen Kjaeraas via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 11:57:49 UTC, ParticlePeter wrote: I need to parse an ascii with multiple tokens. The tokens can be seen as keys. After every token there is a bunch of lines belonging to that token, the values. The order of tokens is unknown. I would like to read the file in as

Re: How do I extend an enum?

2016-03-19 Thread Simen Kjaeraas via Digitalmars-d-learn
On Saturday, 19 March 2016 at 17:40:27 UTC, Lass Safin wrote: Why: enum Base { A, B, } enum Derived : Base { C, // Gives error, says it can't implicitly convert expression to Base. D = 1, // Same error E = cast(Base)294, // Finally works. Can only be cast(Derived) instead

Re: classInstanceSize and vtable

2014-10-23 Thread Simen Kjaeraas via Digitalmars-d-learn
On Friday, 24 October 2014 at 00:21:52 UTC, Etienne Cimon wrote: On 2014-10-23 20:12, bearophile wrote: In D all class instances contain a pointer to the class and a monitor pointer. The table is used for run-time reflection, and for standard virtual methods like toString, etc. Bye, bearophil