Re: hasElaborateCopyConstructor bug?

2019-06-01 Thread SrMordred via Digitalmars-d-learn
On Sunday, 2 June 2019 at 04:02:08 UTC, Paul Backus wrote: On Saturday, 1 June 2019 at 23:29:08 UTC, SrMordred wrote: On Saturday, 1 June 2019 at 21:39:33 UTC, SImen Kjærås wrote: On Saturday, 1 June 2019 at 21:05:32 UTC, SrMordred wrote: Haven't tested it extensively, so use at your own

Re: hasElaborateCopyConstructor bug?

2019-06-01 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 1 June 2019 at 23:29:08 UTC, SrMordred wrote: On Saturday, 1 June 2019 at 21:39:33 UTC, SImen Kjærås wrote: On Saturday, 1 June 2019 at 21:05:32 UTC, SrMordred wrote: hasElaborateCopyConstructor checks if the type defines a postblit[0]. Yes, I know this. But since dmd 2.086

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread David Zhang via Digitalmars-d-learn
On Saturday, 1 June 2019 at 13:00:50 UTC, ag0aep6g wrote: How is setting/replacing different from modifying? e.g.: S s; this() { s = ...; } update(S s) { this.s = s; } mod(int i) { s.i = i; } // illegal Kinda like how strings can be copied and assigned to, but not

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread David Zhang via Digitalmars-d-learn
On Saturday, 1 June 2019 at 16:30:12 UTC, Jonathan M Davis wrote: If any member variable of a struct is const, then you can't modify that member ever, and assignment isn't possible unless you override opAssign so that it overwrites only the mutable members. It's very rare that it makes sense

Re: hasElaborateCopyConstructor bug?

2019-06-01 Thread SrMordred via Digitalmars-d-learn
On Saturday, 1 June 2019 at 21:39:33 UTC, SImen Kjærås wrote: On Saturday, 1 June 2019 at 21:05:32 UTC, SrMordred wrote: hasElaborateCopyConstructor checks if the type defines a postblit[0]. Yes, I know this. But since dmd 2.086 we have copy ctors:

Re: hasElaborateCopyConstructor bug?

2019-06-01 Thread SImen Kjærås via Digitalmars-d-learn
On Saturday, 1 June 2019 at 21:05:32 UTC, SrMordred wrote: import std.traits; struct T { this(ref return scope T other){} } pragma(msg, hasElaborateCopyConstructor!T); //false hasElaborateCopyConstructor checks if the type defines a postblit[0]. That is, a function called this(this).

hasElaborateCopyConstructor bug?

2019-06-01 Thread SrMordred via Digitalmars-d-learn
import std.traits; struct T { this(ref return scope T other){} } pragma(msg, hasElaborateCopyConstructor!T); //false

Re: Calling copyctor manually

2019-06-01 Thread SrMordred via Digitalmars-d-learn
On Saturday, 1 June 2019 at 19:10:36 UTC, Paul Backus wrote: On Saturday, 1 June 2019 at 02:27:36 UTC, SrMordred wrote: void main() { T a; T b; a.__ctor(b); } https://run.dlang.io/is/NeioBs Thanks! The most obvious way i didn´t think :P

Re: Calling copyctor manually

2019-06-01 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 1 June 2019 at 02:27:36 UTC, SrMordred wrote: Its possible to call copyctor manually without calling dtor? ex, what i did before: struct T{ ~this(){ writeln("DTOR"); } this(this){ writeln("POSTBLIT"); } } T a; T b; memcpy(,,T.sizeof); a.__postblit; /* output: POSTBLIT DTOR

Re: How to create a template class using foreach delegate to filter objects in a member function call?

2019-06-01 Thread Alex via Digitalmars-d-learn
On Saturday, 1 June 2019 at 14:24:11 UTC, Robert M. Münch wrote: The myFilter struct is the implementation which myClass.put() should use to iterate over all objects. Which ones? The E-objects, or the objects contained in myClass, which you don't want to know about? All things being only

Why is this pure function taking a string literal not CTFE-executable?

2019-06-01 Thread Simon via Digitalmars-d-learn
Hi Guys! In my programm, I have a custom String-type that I want to initialize some variables of at compile time by casting a string literal to said custom String type. I thought I could achieve this straight forwardly, but after trying a bit, I could not find a (simple) working solution. I

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 1, 2019 6:51:08 AM MDT David Zhang via Digitalmars-d-learn wrote: > Say I have a struct `S`: > > struct S { > /*const*/ char* pointer; > ... other members ... > > this(/*const*/ char* p, ... others ...) { > pointer = p; >

Re: How to create a template class using foreach delegate to filter objects in a member function call?

2019-06-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-06-01 04:43:13 +, Alex said: That's ok, but could you provide an example anyway? Is it like this? ´´´ void main(){ auto target = new myClass!int(); target.objects.length = 4; auto val = 42; put(target, val, testfunction); // does the test function enters here?

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread ag0aep6g via Digitalmars-d-learn
On 01.06.19 14:51, David Zhang wrote:     struct S {     /*const*/ char* pointer;     ... other members ...     this(/*const*/ char* p, ... others ...) {     pointer = p;     ...     }     } What I want, is to be able to use `S` in other data structures

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread drug via Digitalmars-d-learn
01.06.2019 15:55, drug пишет: Is there a type-safe way to do this? If this were a class, I'd try std.typecons.Rebindable. Ah, sorry))

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread drug via Digitalmars-d-learn
01.06.2019 15:51, David Zhang пишет: Say I have a struct `S`:     struct S {     /*const*/ char* pointer;     ... other members ...     this(/*const*/ char* p, ... others ...) {     pointer = p;     ...     }     } What I want, is to be able to use `S`

How to create an overwriteable struct that is always const?

2019-06-01 Thread David Zhang via Digitalmars-d-learn
Say I have a struct `S`: struct S { /*const*/ char* pointer; ... other members ... this(/*const*/ char* p, ... others ...) { pointer = p; ... } } What I want, is to be able to use `S` in other data structures with the following

Re: Dub dependencies / How to use own Github fork?

2019-06-01 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-05-30 18:29:44 +, Steven Schveighoffer said: You can dub add-local your local fork, and it will use that instead of going out to code.dlang.org. Ok, any chance to switch back and forth between local/remote versions? -- Robert M. Münch http://www.saphirion.com smarter | better |

Re: emulate with

2019-06-01 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 31 May 2019 at 08:35:23 UTC, Simen Kjærås wrote: With 1), 2) and 3) fixed, the code would look like this (only changed code included): unittest { with (Dispatcher.X) { A(1); A("a"); B(2); C_Q(3); } } struct Dispatcher { struct

Re: How to create GTK+ apps with Glade and D on windows

2019-06-01 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2019-05-31 at 18:47 +, Obsidian Jackal via Digitalmars-d- learn wrote: > I'm new to D and want to create GTK+ apps. I have Visual Studio, > Glade, the Gtk+ runtime, DMD, and DUB installed. What steps, > guides, or advice should I follow to be able to be able to use > these tools

Re: 'version'-based code selection

2019-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 31, 2019 9:59:13 PM MDT Yatheendra via Digitalmars-d-learn wrote: > Hi people. > > The 'version' keyword sounds like a fantastic capability, but how > far does DMD take it (and does GDC take it equally far)? This is > not a "D Improvement Proposal", I am just asking how it is now.