How can I get this UDA at compile time?

2021-02-20 Thread Jack via Digitalmars-d-learn
I've had a struct like this: struct Attr { string value; } struct Foo { @(Attr("a attr")) enum a = Foo(10); @(Attr("b attr")) enum b = Foo(11); int x; int y; bool doY = true; int value() {

Re: Class instance alignment

2021-02-20 Thread kinke via Digitalmars-d-learn
On Saturday, 20 February 2021 at 18:43:53 UTC, Steven Schveighoffer wrote: Last I checked*, the GC uses pools of 16-byte, 32-byte, 64-byte, etc blocks. That has changed [to reduce wastage]; the new bin sizes are here and include sizes like 176 (11*16):

Re: Strings and Slices

2021-02-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/21 2:31 PM, Mike Brown wrote: On Saturday, 20 February 2021 at 19:28:00 UTC, Mike Brown wrote: On Thursday, 18 February 2021 at 21:08:45 UTC, Adam D. Ruppe wrote: [...] Thank you. Is there a standardised type to make "mark"? size_t or is a normal integer suitable? Ah, and whats

Re: Strings and Slices

2021-02-20 Thread Mike Brown via Digitalmars-d-learn
On Saturday, 20 February 2021 at 19:28:00 UTC, Mike Brown wrote: On Thursday, 18 February 2021 at 21:08:45 UTC, Adam D. Ruppe wrote: [...] Thank you. Is there a standardised type to make "mark"? size_t or is a normal integer suitable? Ah, and whats the recommended way to iterate over a

Re: Strings and Slices

2021-02-20 Thread Mike Brown via Digitalmars-d-learn
On Thursday, 18 February 2021 at 21:08:45 UTC, Adam D. Ruppe wrote: On Thursday, 18 February 2021 at 20:47:33 UTC, Mike Brown wrote: [...] My c++ is rusty af but yes I think so. A d slice is `struct slice { size_t length; T* ptr; }` so when in doubt just think back to what that does.

Re: Class instance alignment

2021-02-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/21 2:13 AM, tsbockman wrote: On Saturday, 20 February 2021 at 05:44:33 UTC, kinke wrote: There's https://github.com/dlang/druntime/blob/728f1d9c3b7a37eba4d59ee2637fb924053cba6d/src/core/internal/traits.d#L261. Thanks! That's helpful. But AFAIK, the GC only guarantees an alignment

Re: Templated delegate as template argument for structs

2021-02-20 Thread Simon van Bernem via Digitalmars-d-learn
Thanks! The alias solution works and is good enough for me. Also thanks for providing the code to typecheck the alias, I would have never been able to come up with that myself.

Re: Templated delegate as template argument for structs

2021-02-20 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 20 February 2021 at 09:16:46 UTC, Simon van Bernem wrote: I have the following struct declaration: struct Hash_Table(Key, Value, u32 delegate(ref Key) custom_hash_function = null) [snip] I take it from the error that the problem is not actually the delegate that I am passing,

Re: Include http based module

2021-02-20 Thread Imperatorn via Digitalmars-d-learn
On Friday, 19 February 2021 at 19:20:39 UTC, tcak wrote: I have written a test module and put it into /var/www/html: module mymodule; import std.stdio; void testMe(){ writeln("I tested you!"); } Then I have a main file where I would like to call the function "testMe". My build line is

Templated delegate as template argument for structs

2021-02-20 Thread Simon van Bernem via Digitalmars-d-learn
I have the following struct declaration: struct Hash_Table(Key, Value, u32 delegate(ref Key) custom_hash_function = null){ ... } When I try to instance the Type like this: Hash_Table!(Component*, Component_Tick_Info, (c) => hash32(c.handle.bitfield)) my_hash_table; I get the

Re: Class instance alignment

2021-02-20 Thread rikki cattermole via Digitalmars-d-learn
On 20/02/2021 8:13 PM, tsbockman wrote: Well, that's just another reason not to use the GC for my current project, then: I'm using 256-bit AVX vectors extensively. You can still use the GC. You just can't use it to allocate the classes you care about.