Re: Lexicographical object comparison by selected members of a struct

2021-08-20 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 21 August 2021 at 04:34:46 UTC, Ali Çehreli wrote: ... Consider __traits(identifier, member) instead. This one should return member name as string, removing the need of memberName function. Also you could have an annotation @Equality.Include for example, and make mixin scan

Re: Lexicographical object comparison by selected members of a struct

2021-08-20 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Saturday, 21 August 2021 at 05:34:59 UTC, Alexandru Ermicioi wrote: ... Also there is no need for mixing string code here. You can get the field using __traits(getMember, this, member).

Lexicographical object comparison by selected members of a struct

2021-08-20 Thread Ali Çehreli via Digitalmars-d-learn
Sometimes I need comparison operators that should consider only some members of a struct: struct S { int year; // Primary member int month;// Secondary member string[] values; // Irrelevant } I've been using the laziest tuple+tupleof solution in some of my structs:

Re: How to get element type of a slice?

2021-08-20 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 19 August 2021 at 04:03:31 UTC, jfondren wrote: On Thursday, 19 August 2021 at 03:32:47 UTC, Jesse Phillips wrote: On Tuesday, 17 August 2021 at 12:33:03 UTC, Ferhat Kurtulmuş wrote: Hey, thank you again but, I don't want an instance of Point[] I need: alias T = Point[]; alias

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-20 Thread jfondren via Digitalmars-d-learn
On Friday, 20 August 2021 at 21:19:09 UTC, Ruby The Roobster wrote: MessageBoxA(null, "Error", cast(char)[])e.msg,MB_OK | ICON_ERROR); use std.string.toStringz to ensure that e.msg is 0-terminated.

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-20 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 20 August 2021 at 05:22:20 UTC, nov wrote: On Friday, 20 August 2021 at 04:27:34 UTC, Jesse Phillips wrote: For me, this code generates the Message Box. Does this happen for you? no errors https://run.dlang.io/is/4tlm3p ```D void main() { try { import std.stdio: File;

Re: Vibe.d error

2021-08-20 Thread JG via Digitalmars-d-learn
On Friday, 20 August 2021 at 10:50:12 UTC, WebFreak001 wrote: On Wednesday, 18 August 2021 at 19:51:00 UTC, JG wrote: [...] There might be incompatibilities with how openssl is used and the installed openssl version or config. If you are getting this from having https enabled on the

Re: Why the very same code works in main and not in unittest?

2021-08-20 Thread jfondren via Digitalmars-d-learn
On Friday, 20 August 2021 at 16:02:22 UTC, Pablo De Nápoli wrote: Consider the following code: void main() { mpd_context_t ctx; mpd_t* a; mpd_ieee_context(, 128); a= mpd_new(); } It seems to work fine. ... However, if I put the very same code in the

Re: classify a user struct as an "array" or "slice"

2021-08-20 Thread james.p.leblanc via Digitalmars-d-learn
On Friday, 20 August 2021 at 15:38:04 UTC, Paul Backus wrote: The most straightforward way would be to change your functions from accepting only `T[]` to accepting either `T[]` or `fakeArray`. For example: ```d import std.traits: isDynamicArray; // assuming `fakeArray` is a template

Why the very same code works in main and not in unittest?

2021-08-20 Thread Pablo De Nápoli via Digitalmars-d-learn
Still working on my project of a D wrapped for libmpdec (https://www.bytereef.org/mpdecimal/). Consider the following code: void main() { mpd_context_t ctx; mpd_t* a; mpd_ieee_context(, 128); a= mpd_new(); } It seems to work fine. mpd_new is a C function

Re: classify a user struct as an "array" or "slice"

2021-08-20 Thread Paul Backus via Digitalmars-d-learn
On Friday, 20 August 2021 at 15:12:25 UTC, james.p.leblanc wrote: Greetings, I have a user created struct, let's call this "**fakeArray**": For all intents and purposes fakeArray behaves like an array (or slice, I guess). (i.e. It has a number of operator overloadings, and *foreach*

classify a user struct as an "array" or "slice"

2021-08-20 Thread james.p.leblanc via Digitalmars-d-learn
Greetings, I have a user created struct, let's call this "**fakeArray**": For all intents and purposes fakeArray behaves like an array (or slice, I guess). (i.e. It has a number of operator overloadings, and *foreach* extensions implemented.) I have a fairly large number of function in a

Re: D equivalent of C++ explicit

2021-08-20 Thread Tejas via Digitalmars-d-learn
On Friday, 20 August 2021 at 05:43:49 UTC, evilrat wrote: On Thursday, 19 August 2021 at 18:04:58 UTC, Tejas wrote: On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote: On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote: As the topic says: Is there an equivalent to C++'s

Re: Vibe.d error

2021-08-20 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 18 August 2021 at 19:51:00 UTC, JG wrote: Hi, We are intermittently getting the following error: Accept TLS connection: server OpenSSL error at ../ssl/record/rec_layer_s3.c:1543: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown (SSL alert number 46)

Re: std.stdio.File is throwing with the message of: "Access Violation"

2021-08-20 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 18 August 2021 at 17:56:53 UTC, Ruby The Roobster wrote: When I removed those two lines of code, the program ran perfectly without displaying any error or throwing any exception... The errors aren't always nicely located and can be elsewhere. Try to write a minimal runnable