can't run D project on Visual studio

2020-02-13 Thread Akomire Samson via Digitalmars-d-learn
I am having this error on running D project using Visual studio 2019 and Visual D Build Log Building Win32\Debug\LearningD.exe Command Line set PATH=C:\D\ldc2-1.19.0-windows-multilib\bin;C:\Program Files (x86)\Microsoft Visual

How do you find the struct types in a module? - getting Error: unknown

2020-02-13 Thread aliak via Digitalmars-d-learn
Hi, I'm trying to get a typed list of structs in my current module that matches certain criteria. Something like: module mod; struct X {} struct Y {} alias allTypes = ListOfTypes!mod; But I'm having a bit of trouble. I have this so far: template ListOfTypes(alias T) { import std.meta;

Re: writeln() in static import std

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 2:33 AM, Adnan wrote: How can I reach stdout.writeln() using fully qualified name with static import? I have tried: std.stdio.stdout.writeln() -- fails std.writeln() -- works std.stdout.writeln -- works How does static import with std work? Hm..., this works: static import

Re: How do you find the struct types in a module? - getting Error: unknown

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 9:47 AM, aliak wrote: Hi, I'm trying to get a typed list of structs in my current module that matches certain criteria. Something like: module mod; struct X {} struct Y {} alias allTypes = ListOfTypes!mod; But I'm having a bit of trouble. I have this so far: template

Re: Unpack Variadic Args?

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 11:29 AM, Jeff wrote: On Thursday, 13 February 2020 at 08:06:52 UTC, Paul Backus wrote: Variadic template arguments unpack automatically in D, so you don't need to do anything special here:     void g(Args...)(auto ref Args args) {     import core.lifetime: forward; // like

Re: Unpack Variadic Args?

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 12:18 PM, Adam D. Ruppe wrote: On Thursday, 13 February 2020 at 17:13:31 UTC, Steven Schveighoffer wrote: the f(foo(args)...) syntax doesn't have a D equivalent. It would be staticMap f(staticMap!(foo, args)) No,

Re: Unpack Variadic Args?

2020-02-13 Thread Jeff via Digitalmars-d-learn
On Thursday, 13 February 2020 at 08:06:52 UTC, Paul Backus wrote: On Thursday, 13 February 2020 at 07:06:49 UTC, Jeff wrote: Hello, Was wondering if there was a simple, efficient way to unpack a variadic template argument. It needs to be efficient at runtime, and hopefully not use too much

Re: Unpack Variadic Args?

2020-02-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 February 2020 at 17:13:31 UTC, Steven Schveighoffer wrote: the f(foo(args)...) syntax doesn't have a D equivalent. It would be staticMap f(staticMap!(foo, args)) staticMap is a recursive template

Dscanner: is it possible to switch off style checks case-by-case?

2020-02-13 Thread mark via Digitalmars-d-learn
I'm starting out with GtkD and have this function: void main(string[] args) { Main.init(args); auto game = new GameWindow(); Main.run(); } and this method: void quit(Widget widget) { Main.quit(); } When I run dscanner --styleCheck it reports:

Re: Type sequence concatenation / associative array implementation

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/20 5:47 PM, Paul Backus wrote: On Wednesday, 12 February 2020 at 20:58:49 UTC, Marcel wrote: 2- How is the builtin associative array implemented? I think I read somewhere it's implemented like C++'s std::unordered_map but with BSTs instead of DLists for handling collisions: is this

Re: Unpack Variadic Args?

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 12:24 PM, Steven Schveighoffer wrote: But this means you have an additional function call (which could of course be inlined). And I might add, an additional requirement to declare some other template (one of the huge drawbacks of std.meta, IMO). Some syntax like

Re: Unpack Variadic Args?

2020-02-13 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 13, 2020 at 12:32:01PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > Some syntax like expr(someTuple)... would be really cool to have in D. > > Or something like arg => expr syntax for templates might be useful: > > f(staticMap!(!a => foo(a), args)); // look ma,

How to get to body of HTTP 500 error with std.net.curl.get()?

2020-02-13 Thread Gregor Mückl via Digitalmars-d-learn
Hi! I am trying to write a client for pretty... well... creatively designed web API. The server gives HTTP status 500 replies if the requests are malformed, but the actual error message is hidden in the body of the reply (an XML document!). std.net.curl.get() throws an exception in this

How to use labeled break in static foreach?

2020-02-13 Thread cc via Digitalmars-d-learn
import std.meta; enum A = AliasSeq!(1, 2, 3, 4); THREELOOP: static foreach (idx, field; A) { static if (field == 3) { pragma(msg, "Got a 3!"); break THREELOOP; } static if (idx == A.length - 1) { static assert(0, "Got no

Re: How to use labeled break in static foreach?

2020-02-13 Thread cc via Digitalmars-d-learn
Here's a more involved example of what I'm trying to accomplish. Is there an easier/cleaner way to do this? (This is still a bit reduced, what I'm actually trying to do is compare whether a given variadic typetuple passed to opDispatch is implicitly convertible to one of the parameter

Re: How do you find the struct types in a module? - getting Error: unknown

2020-02-13 Thread aliak via Digitalmars-d-learn
On Thursday, 13 February 2020 at 15:38:37 UTC, Steven Schveighoffer wrote: On 2/13/20 9:47 AM, aliak wrote: [...] Not sure about your error, but here is a working version (don't use mixins, use __traits(getMember)): import std.meta; template ListOfStructs(alias mod) { enum

Re: Overfflow in Assert error messages

2020-02-13 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 13 February 2020 at 07:49:13 UTC, Adnan wrote: However my test fails saying something like: source/binary_search.d(33): [unittest] 18446744073709551615 != 1 core.exception.AssertError@source/binary_search.d(33): 18446744073709551615 != 1 What's causing this underflow? It's

Re: Unpack Variadic Args?

2020-02-13 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 13 February 2020 at 07:06:49 UTC, Jeff wrote: Hello, Was wondering if there was a simple, efficient way to unpack a variadic template argument. It needs to be efficient at runtime, and hopefully not use too much excessive CTFE. C++ has the "..." operator, is there something