Re: Trait for "can be instantiated"?

2022-05-09 Thread ag0aep6g via Digitalmars-d-learn
On 09.05.22 23:24, Ben Jones wrote: enum x; enum y = 5; struct Wrap(alias T) {     static if(isType!T){ T value; //When t == x this doesn't work because `x` is opaque and has no default initializer     } } [...] x is a "type" as far as isType is concerned (which makes sense to m

Re: range result in Tuple! and how to convert into assocArray by sort?

2022-05-09 Thread MichaelBi via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 04:21:04 UTC, Ali Çehreli wrote: On 5/9/22 20:38, rikki cattermole wrote: > [...] Yes! :) Assuming the data is indeed validated in some way, the following should be even faster. It validates the data after the fact: [...] this is cool! thanks for your time and

Re: range result in Tuple! and how to convert into assocArray by sort?

2022-05-09 Thread MichaelBi via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 03:38:08 UTC, rikki cattermole wrote: If I am understanding the problem correctly, this is a super expensive method for doing something pretty simple. Even if it is a bit more code, this won't require memory allocation which in this case wouldn't be cheap (given how b

Re: Trait for "can be instantiated"?

2022-05-09 Thread Ali Çehreli via Digitalmars-d-learn
On 5/9/22 20:52, Ben Jones wrote: > Using is(T) instead of isType!T also appears to be true for the > un-instantiate-able enum. Was your point just that I could replace > isType!T with is(T)? I just found something that looked like a workaround. I don't know whether it is by design or by accid

Re: range result in Tuple! and how to convert into assocArray by sort?

2022-05-09 Thread Ali Çehreli via Digitalmars-d-learn
On 5/9/22 20:38, rikki cattermole wrote: > this is a super expensive > method for doing something pretty simple. Yes! :) Assuming the data is indeed validated in some way, the following should be even faster. It validates the data after the fact: import std.stdio; import std.range; import st

Re: Trait for "can be instantiated"?

2022-05-09 Thread Ben Jones via Digitalmars-d-learn
On Monday, 9 May 2022 at 21:58:59 UTC, Ali Çehreli wrote: On 5/9/22 14:24, Ben Jones wrote: > Is there a trait that can tell if you > can initialize a variable of a certain type? Not answering that question but the 'is' expression seems to work in this case: static if(is (T)) {

Re: range result in Tuple! and how to convert into assocArray by sort?

2022-05-09 Thread rikki cattermole via Digitalmars-d-learn
If I am understanding the problem correctly, this is a super expensive method for doing something pretty simple. Even if it is a bit more code, this won't require memory allocation which in this case wouldn't be cheap (given how big DNA tends to be). string s = "ACGTACGT"; uint[4] counts; fo

range result in Tuple! and how to convert into assocArray by sort?

2022-05-09 Thread MichaelBi via Digitalmars-d-learn
s is the string, and print result as following: s.array.sort!("athen how to transfer into [['A',231],['C',247],['G',240],['T',209]]? tried map!, but can only sortout key or value... tried array(), but result is not sorted then...thanks in advance.

Re: Parameters of overloaded templated function

2022-05-09 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 01:00:24 UTC, frame wrote: So `__traits(getOverloads)` returns also templated members and `__traits(isTemplate)` can select those members. Unfortunately, `Parameters!` does not work with the templated member. How can I pass a symbol of T or A... to `Parameters!` as de

Re: How to convert a LPCWSTR aka const(wchar)* to string

2022-05-09 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 01:07:37 UTC, Mike Parker wrote: ```d import std.conv : to; string s = to!string(pszUserString); ``` Thanks, it worked. At first, I tried `to!string` but it failed because of this usage-- ```d this(LPCWSTR dtpStr) { this.dateString = to!string(LPCWSTR)(dtpStr) ; }

Re: How to convert a LPCWSTR aka const(wchar)* to string

2022-05-09 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 00:50:09 UTC, Vinod K Chandran wrote: I want to convert this `pszUserString` to a string. How to do it. Thanks in advance. ```d import std.conv : to; string s = to!string(pszUserString); ```

Parameters of overloaded templated function

2022-05-09 Thread frame via Digitalmars-d-learn
So `__traits(getOverloads)` returns also templated members and `__traits(isTemplate)` can select those members. Unfortunately, `Parameters!` does not work with the templated member. How can I pass a symbol of T or A... to `Parameters!` as desired type without instantiating the template? ```d

How to convert a LPCWSTR aka const(wchar)* to string

2022-05-09 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all. I want to convert an LPCWSTR to string. I have a struct like this ```cpp typedef struct tagNMDATETIMESTRINGW { NMHDR nmhdr; LPCWSTRpszUserString; SYSTEMTIME st; DWORD dwFlags; } NMDATETIMESTRINGW, *LPNMDATETIMESTRINGW; ``` I want to convert this `pszUserString` to a s

Re: Trait for "can be instantiated"?

2022-05-09 Thread Ali Çehreli via Digitalmars-d-learn
On 5/9/22 14:24, Ben Jones wrote: > Is there a trait that can tell if you > can initialize a variable of a certain type? Not answering that question but the 'is' expression seems to work in this case: static if(is (T)) { T value; } https://dlang.org/spec/expression.html#Is

Trait for "can be instantiated"?

2022-05-09 Thread Ben Jones via Digitalmars-d-learn
I have a struct template that takes an alias parameter and I'm trying to distinguish between type parameters and enum values. std.traits.isType works for this except for one edge case: ``` import std.traits; import std.stdio; struct S{} enum x; enum y = 5; struct Wrap(alias T) { static i

Re: Deploy vibe.d application on Heroku : App not compatible with buildpack

2022-05-09 Thread MichaelBi via Digitalmars-d-learn
On Monday, 28 June 2021 at 16:25:20 UTC, vnr wrote: On Monday, 28 June 2021 at 16:14:07 UTC, Andre Pany wrote: On Monday, 28 June 2021 at 13:53:05 UTC, vnr wrote: [...] Hi, Heroku is Cloud Foundry? If yes, you can make use of the binary buildpack or deploying your app as container too. Ki

Re: Including C sources in a DUB project

2022-05-09 Thread Alexander Zhirov via Digitalmars-d-learn
On Friday, 6 May 2022 at 11:31:27 UTC, Alexander Zhirov wrote: Does anyone have examples of such a configuration? I managed to do it like this: ```js { "name": "app", "authors": [ "Alexander Zhirov" ], "description": "MyProgram", "dflags": [ "-i" ],