On Tuesday, 12 July 2022 at 13:34:42 UTC, rempas wrote:
[...]
Thank you all for your help!
@Ali Çehreli
That makes things much much easier! I'll look at the source code
in "traits.d" and I'll copy-paste it into my library ;)
On Tuesday, 12 July 2022 at 15:30:03 UTC, Ali Çehreli wrote:
An alternative:
https://dlang.org/phobos/std_traits.html#isInstanceOf
This is a really good alternative. Because I used to have to
write longer. Thanks, the LOG thing is better now:
```d
struct LOG(T...) {
T[0] id;
T[1]
On 7/12/22 06:34, rempas wrote:
>static if (is(typeof(obj) == Test)) { printf("YES!!!\n"); }
An alternative:
import std.traits;
static if (isInstanceOf!(Test, typeof(obj))) { printf("YES!!!\n"); }
https://dlang.org/phobos/std_traits.html#isInstanceOf
Ali
On Tuesday, 12 July 2022 at 13:56:11 UTC, rempas wrote:
On Tuesday, 12 July 2022 at 13:37:49 UTC, ag0aep6g wrote:
static if (is(typeof(obj) == Test!T, T)) {
printf("YES!!!\n"); }
Haah? Ok, what does this work anyway? I thought you needed
parenthesis for more than 1 templated
On Tue, Jul 12, 2022 at 01:56:11PM +, rempas via Digitalmars-d-learn wrote:
> On Tuesday, 12 July 2022 at 13:37:49 UTC, ag0aep6g wrote:
> >
> > static if (is(typeof(obj) == Test!T, T)) { printf("YES!!!\n"); }
>
> Haah? Ok, what does this work anyway? I thought you needed
>
On Tuesday, 12 July 2022 at 13:37:49 UTC, ag0aep6g wrote:
static if (is(typeof(obj) == Test!T, T)) {
printf("YES!!!\n"); }
Haah? Ok, what does this work anyway? I thought you needed
parenthesis for more than 1 templated arguments...
On 12.07.22 15:34, rempas wrote:
extern (C) void main() {
auto obj = make_test(20);
static if (is(typeof(obj) == Test)) { printf("YES!!!\n"); }
}
static if (is(typeof(obj) == Test!T, T)) { printf("YES!!!\n"); }
I want to do something like the following:
```d
import core.stdc.stdio;
Test!(T, "mode1") make_test(T)(T data) {
Test!(T, "mode1") t = { data };
return t;
}
struct Test(T, string mode = "ref") { T data; }
extern (C) void main() {
auto obj = make_test(20);
static if (is(typeof(obj) ==