Re: static weirdness

2018-01-25 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 02:01:54 UTC, Jonathan M Davis wrote: (so there's no need to dereference the pointer to call it) It used to check this pointer with an assert. When did it change?

BitFlags usage

2018-01-25 Thread Alex via Digitalmars-d-learn
I have a question on usage of BitFlags, described here: https://dlang.org/library/std/typecons/bit_flags.html and/or on bitop https://dlang.org/phobos/core_bitop.html#.bsf A similar example to the bit flags example is given here: [code] import std.typecons; enum Rs : ubyte { None,

Re: static weirdness

2018-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 25, 2018 10:17:34 Kagamin via Digitalmars-d-learn wrote: > On Wednesday, 24 January 2018 at 02:01:54 UTC, Jonathan M Davis > > wrote: > > (so there's no need to dereference the pointer to call it) > > It used to check this pointer with an assert. When did it change? Actually,

Re: static weirdness

2018-01-25 Thread Alex via Digitalmars-d-learn
On Thursday, 25 January 2018 at 10:17:34 UTC, Kagamin wrote: On Wednesday, 24 January 2018 at 02:01:54 UTC, Jonathan M Davis wrote: (so there's no need to dereference the pointer to call it) It used to check this pointer with an assert. When did it change? Fortunately, I have some compilers

Re: static weirdness

2018-01-25 Thread Alex via Digitalmars-d-learn
On Thursday, 25 January 2018 at 12:06:07 UTC, Jonathan M Davis wrote: On Thursday, January 25, 2018 10:17:34 Kagamin via Digitalmars-d-learn wrote: On Wednesday, 24 January 2018 at 02:01:54 UTC, Jonathan M Davis wrote: > (so there's no need to dereference the pointer to call it) It used to che

Re: static weirdness

2018-01-25 Thread Kagamin via Digitalmars-d-learn
On Thursday, 25 January 2018 at 12:06:07 UTC, Jonathan M Davis wrote: Actually, assert on a pointer to a struct or a reference to a class checks for null _and_ calls the invariant, and that hasn't changed. But you have to actually assert the pointer or reference if you want to do that, and the

Re: static weirdness

2018-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 25, 2018 12:38:25 Kagamin via Digitalmars-d-learn wrote: > On Thursday, 25 January 2018 at 12:06:07 UTC, Jonathan M Davis > > wrote: > > Actually, assert on a pointer to a struct or a reference to a > > class checks for null _and_ calls the invariant, and that > > hasn't chang

Re: static weirdness

2018-01-25 Thread Kagamin via Digitalmars-d-learn
See https://ideone.com/VZ97dh

Re: static weirdness

2018-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 25, 2018 12:42:57 Kagamin via Digitalmars-d-learn wrote: > See https://ideone.com/VZ97dh I don't know what's going on there. Such an assertion does not seem in line with what Walter has typically said on the subject. Thinking about it, I do vaguely recall a discussion someti

Re: BitFlags usage

2018-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 01/25/2018 03:50 AM, Alex wrote:     r |= cast(BitFlags!Rs)val; // line 20 ... from asignment r |= BitFlags!Rs(cast(Rs)val); Ali

Re: BitFlags usage

2018-01-25 Thread Alex via Digitalmars-d-learn
On Thursday, 25 January 2018 at 13:05:07 UTC, Ali Çehreli wrote: On 01/25/2018 03:50 AM, Alex wrote:     r |= cast(BitFlags!Rs)val; // line 20 ... from asignment r |= BitFlags!Rs(cast(Rs)val); Ali Thanks :)

Re: static weirdness

2018-01-25 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 25 January 2018 at 12:58:12 UTC, Jonathan M Davis wrote: Thinking about it, I do vaguely recall a discussion sometime last year about an invariant being invisibly inserted under some set of circumstances. Maybe that's what's happening? I believe that it was complained about in th

Re: static weirdness

2018-01-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/25/18 8:24 AM, Mike Parker wrote: On Thursday, 25 January 2018 at 12:58:12 UTC, Jonathan M Davis wrote: Thinking about it, I do vaguely recall a discussion sometime last year about an invariant being invisibly inserted under some set of circumstances. Maybe that's what's happening? I beli

Using std traits

2018-01-25 Thread JN via Digitalmars-d-learn
I decided it's time to learn how std traits work. I still find the whole compile time business a bit weird to deal with, so I decided to write a simple JSON serializer for struct that loops over member fields and outputs them. import std.stdio; import std.json; import std.traits; struct TestS

Re: Using std traits

2018-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 01/25/2018 11:49 AM, JN wrote:     foreach (i, member; FieldNameTuple!T)     {     if (!hasUDA!(member, "noserialize"))     {     writeln(member);     } 'member' is a string local variable, which does not have that UDA. You need to get the

Re: Using std traits

2018-01-25 Thread JN via Digitalmars-d-learn
On Thursday, 25 January 2018 at 19:49:05 UTC, JN wrote: if (!hasUDA!(member, "noserialize")) Nevermind, I get it now, member is only the field name, not a 'reference', changed it to: if (!hasUDA!(mixin(T.stringof ~ "." ~ member), "noserialize")) and works now

Re: Class instance memory overhead lower than 3 words?

2018-01-25 Thread kinke via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 21:48:21 UTC, Nordlöw wrote: Why is the memory overhead for a class instance as high as 3 words (24 bytes on 64-bit systems? I find that annoyingly much for my knowledge database application. I'm aware of extern(C++), having one word overhead, but such extern(C

curl_mime_init: How to get curl handle?

2018-01-25 Thread Andre Pany via Digitalmars-d-learn
Hi, I need to send multipart form data using curl. Until now I build the message body myself according to the HTML RFC but it is getting complex with large files causing Out Of Memory Exceptions. Low level curl supports multipart form data and I think I copied the C headers accordingly. The