Re: How to return a reference to structs?

2021-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/5/21 5:43 PM, Andrey Zherikov wrote: In case others want to work, here are the modules that need to be imported: import std.algorithm; import std.range; import std.stdio; > struct A {} > struct B > { > A[] ar = [A.init]; > size_t[] idx = [0]; I don't know why but those initial

Re: How to return a reference to structs?

2021-11-05 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 5 November 2021 at 20:13:02 UTC, Andrey Zherikov wrote: On Friday, 5 November 2021 at 19:49:50 UTC, Ali Çehreli wrote: Indexes are typed as size_t, which is ulong for 64-bit and uint for 32-bit. If idx elements were indeed indexes, it should have been typed as size_t: size_t[] idx

Re: How to return a reference to structs?

2021-11-05 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 5 November 2021 at 19:49:50 UTC, Ali Çehreli wrote: Indexes are typed as size_t, which is ulong for 64-bit and uint for 32-bit. If idx elements were indeed indexes, it should have been typed as size_t: size_t[] idx = [1,3,4]; // <-- Here Ah, good point. Thanks!

Re: How to return a reference to structs?

2021-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/5/21 11:44 AM, kdevel wrote: > On Thursday, 4 November 2021 at 11:26:30 UTC, Andrey Zherikov wrote: >> I have the following code example: > > [...] > >> A[5] a; >> ulong[] idx = [1,3,4]; > > [...] > >> return idx.map!(_ => a[_]); > > How can one make the type of idx's elements portable (

Re: Crosscompile to Windows

2021-11-05 Thread Imperatorn via Digitalmars-d-learn
On Friday, 5 November 2021 at 18:11:35 UTC, Luis wrote: There is a obvious way to crosscompile a dub project to Windows from a Linux dev machine ? https://forum.dlang.org/thread/qnsbjdamttlklurnp...@forum.dlang.org

Re: Crosscompile to Windows

2021-11-05 Thread Imperatorn via Digitalmars-d-learn
On Friday, 5 November 2021 at 18:23:29 UTC, Luis wrote: On Friday, 5 November 2021 at 18:13:03 UTC, Imperatorn wrote: On Friday, 5 November 2021 at 18:11:35 UTC, Luis wrote: There is a obvious way to crosscompile a dub project to Windows from a Linux dev machine ? Wine 😎 Ideally should be s

Re: How to return a reference to structs?

2021-11-05 Thread kdevel via Digitalmars-d-learn
On Thursday, 4 November 2021 at 11:26:30 UTC, Andrey Zherikov wrote: I have the following code example: [...] A[5] a; ulong[] idx = [1,3,4]; [...] return idx.map!(_ => a[_]); How can one make the type of idx's elements portable (compile with -m32 to see what the problem is)? This s

Re: Crosscompile to Windows

2021-11-05 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 5 November 2021 at 18:11:35 UTC, Luis wrote: There is a obvious way to crosscompile a dub project to Windows from a Linux dev machine ? I don't know if it is possible with dmd. But with LDC you can use mtriple. https://wiki.dlang.org/Cross-compiling_with_LDC

Re: Crosscompile to Windows

2021-11-05 Thread Luis via Digitalmars-d-learn
On Friday, 5 November 2021 at 18:13:03 UTC, Imperatorn wrote: On Friday, 5 November 2021 at 18:11:35 UTC, Luis wrote: There is a obvious way to crosscompile a dub project to Windows from a Linux dev machine ? Wine 😎 Ideally should be something like `dub build -target=x64-windows` or somethi

Re: How do I assign attributes of a function to another function?

2021-11-05 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 5 November 2021 at 06:19:16 UTC, Li30U wrote: ...e.g. ```d // ... mixin ("ReturnType /*...snip...*/ " ~ member ~ "()(Parameters! /*...snip...*/ ``` Note the `()` before parameter list. This would make your member function a function template, for which attributes will be inferred

Crosscompile to Windows

2021-11-05 Thread Luis via Digitalmars-d-learn
There is a obvious way to crosscompile a dub project to Windows from a Linux dev machine ?

Re: Crosscompile to Windows

2021-11-05 Thread Imperatorn via Digitalmars-d-learn
On Friday, 5 November 2021 at 18:11:35 UTC, Luis wrote: There is a obvious way to crosscompile a dub project to Windows from a Linux dev machine ? Wine 😎

Re: How do I assign attributes of a function to another function?

2021-11-05 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 5 November 2021 at 06:19:16 UTC, Li30U wrote: I am creating a templated object that is a storehouse for a heap object and executes their methods and returns an array of results. With the help of a template, I want to achieve this, but I want to assign the same attributes to the funct