Re: Why does this code only work with `T` and not `typeof(T)`?

2023-01-03 Thread thebluepandabear via Digitalmars-d-learn
On Wednesday, 4 January 2023 at 04:42:08 UTC, Ali Çehreli wrote: On 1/3/23 20:11, thebluepandabear wrote: > if I replace the `isDrawable` template with the > following (using `typeof`), the code does not compile: It must be because T is already a type. It's the same reason why the following

Re: Why does this code only work with `T` and not `typeof(T)`?

2023-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 1/3/23 20:11, thebluepandabear wrote: > if I replace the `isDrawable` template with the > following (using `typeof`), the code does not compile: It must be because T is already a type. It's the same reason why the following code fails to compile: void main() { alias T = int; alias

Re: Is there a way to enforce UFCS?

2023-01-03 Thread Ali Çehreli via Digitalmars-d-learn
On 1/3/23 19:42, thebluepandabear wrote: > @property { As your post proves, that feature is at most half-baked and is discouraged. Today, there is just one known obscure effect of using it. > void name(string name) { > _name = name; > } > d.name =

Why does this code only work with `T` and not `typeof(T)`?

2023-01-03 Thread thebluepandabear via Digitalmars-d-learn
I am using the CSFML D bindings, and I am creating my own `draw` template function. I first check that the object passed in is of the appropriate type, and if it is, I call the appropriate function: ```D template isDrawable(T) { enum isDrawable = is(T == sfCircleShape*) || is(T ==

Re: Address of a class object

2023-01-03 Thread Paul via Digitalmars-d-learn
matheus, using dmd64 on my laptop to compile and run this: ```d import std.stdio, std.traits; class MyClass {char[16] c;} void main() { writeln(" Size Alignment Type\n", "="); size_t size = __traits(classInstanceSize, MyClass); size_t alignment

Is there a way to enforce UFCS?

2023-01-03 Thread thebluepandabear via Digitalmars-d-learn
Say you have the following class which represents a dog : ```D class Dog { @property { string name(); void name(string name) { _name = name; } } private { string _name; } } ``` And you have the following code with constructs a `Dog`

Re: Solving optimization problems with D

2023-01-03 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 3 January 2023 at 21:13:55 UTC, Sergey wrote: On Sunday, 1 January 2023 at 21:11:06 UTC, Ogi wrote: I’ve read this [series if articles](https://www.gamedeveloper.com/design/decision-modeling-and-optimization-in-game-design-part-1-introduction) about using Excel Solver for all kinds

Re: Solving optimization problems with D

2023-01-03 Thread jmh530 via Digitalmars-d-learn
On Sunday, 1 January 2023 at 22:00:29 UTC, max haughton wrote: On Sunday, 1 January 2023 at 21:11:06 UTC, Ogi wrote: I’ve read this [series if articles](https://www.gamedeveloper.com/design/decision-modeling-and-optimization-in-game-design-part-1-introduction) about using Excel Solver for all

Re: Solving optimization problems with D

2023-01-03 Thread Sergey via Digitalmars-d-learn
On Sunday, 1 January 2023 at 21:11:06 UTC, Ogi wrote: I’ve read this [series if articles](https://www.gamedeveloper.com/design/decision-modeling-and-optimization-in-game-design-part-1-introduction) about using Excel Solver for all kinds of optimization problems. This is very neat, but of course,

Re: How should I return multiple const values from a function?

2023-01-03 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 3 January 2023 at 07:41:46 UTC, Salih Dincer wrote: P.S. Actually the code works when we don't use enum. My mistake, I forgot that enum cannot be inferred! Very very sorry, suppose I didn't intervene  Also this has worked: ```d void main() { template Fun(Key, Value) {