Re: Auto recursive function

2017-01-12 Thread Bauss via Digitalmars-d-learn
On Thursday, 12 January 2017 at 00:30:33 UTC, Ignacious wrote: On Wednesday, 11 January 2017 at 19:23:10 UTC, Razvan Nitu wrote: [...] If you change the return type to a void* your code basically works. void* makeMultidimensionalArray(T, Allocator)(auto ref Allocator alloc, size_t[] leng

Re: Auto recursive function

2017-01-12 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 11 January 2017 at 19:23:10 UTC, Razvan Nitu wrote: Hi, I am currently trying to create a function makeMultidimensionalArray which allocates memory for a multidimensional array. You were very close to the answer: auto makeMultidimensionalArray(int N, T, Allocator)(auto ref Al

Re: Primality test function doesn't work on large numbers?

2017-01-12 Thread Timon Gehr via Digitalmars-d-learn
On 10.01.2017 04:02, Elronnd wrote: Thank you! Would you mind telling me what you changed aside from pow() and powm()? 1. This code: // make 2^a = integer-1 while ((integer-1)%(pow(bigint(2), a))!=0) a--; m = (integer-1) / pow(bigint(2), a); a starts out as integer-1, so this computes ma

Unexpected behavior when using both alias this and object pointer

2017-01-12 Thread xiren7 via Digitalmars-d-learn
The problem and the code: import std.stdio: writeln; import core.stdc.stdlib: malloc; struct Impl { ubyte[8] payload; } class Foo { Impl *impl; alias impl this; this() { impl = cast(Impl*) malloc(Impl.sizeof); } } class Foo2 { ubyte[8] payload; } void main

Is there a way to get a compile-time list of all user classes?

2017-01-12 Thread Max via Digitalmars-d-learn
Hello, I would like to get as a result a list of all classes that implement a specific user interface. Is there a way to do this?

Re: Is there a way to get a compile-time list of all user classes?

2017-01-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 12 January 2017 at 20:58:33 UTC, Max wrote: I would like to get as a result a list of all classes that implement a specific user interface. Is there a way to do this? Not at compile time, it is possible there are child classes in separately compiled modules or libraries (or even r

Re: Unexpected behavior when using both alias this and object pointer

2017-01-12 Thread Ali Çehreli via Digitalmars-d-learn
Hiding a Foo right after Impl can be a solution. However, you need to pass 't', not '&t' to the C function because - Although it may be unexpected, cast(void*) is the specified way of getting the address of a class object - Taking the address of a class reference (which 't' is one), is just

MSVC path on windows

2017-01-12 Thread Jeremy DeHaan via Digitalmars-d-learn
I'm trying to automate a build process for a project of mine, and I want to get the path to the MSVC toolchain DMD is using. I don't want to hard code any paths that may not work on some people's set-ups. I know there are some environmental variables such as VS140COMNTOOLS, VS120COMNTOOLS, et

Re: MSVC path on windows

2017-01-12 Thread Ryan via Digitalmars-d-learn
On Friday, 13 January 2017 at 03:21:52 UTC, Jeremy DeHaan wrote: I've also thought of parsing the PATH to figure out where dmd is installed and extract the info from the sc.ini file. I have both VS2013 and VS2015 installed. I have to use a project specific sc.ini file to match each project to

Merging two arrays in a uniform order

2017-01-12 Thread aberba via Digitalmars-d-learn
Unlike array1 + array2, how can i merge arrays such that: [a1, a1, a2, a1, a1, a2, a1] //uniform order where a1 = child of array1, a2 = child of array2 using a built-in function/algorithm (is/are there anything(s) in Phobos for this?). No manual approach.

Re: Unexpected behavior when using both alias this and object pointer

2017-01-12 Thread xiren7 via Digitalmars-d-learn
Thanks. Ali. My previous post is not clear that I have to store class reference(object pointer) in void*. My actual code is try to use libuv in D. // genarated from uv.h, only two fields is used: 'data', 'type'. // the document of 'data': "Space for user-defined arbitrary data. libuv does not