On 06/19/2016 12:45 PM, Gary Willoughby wrote:
On Sunday, 19 June 2016 at 10:35:59 UTC, Gary Willoughby wrote:
...
A more correct example:
import core.stdc.stdlib;
import std.traits;
ref T foo(T)()
{
alias Type = Unqual!(T);
Type* foo = cast(Type*) malloc(Type.sizeof * 8);
On Sunday, 19 June 2016 at 10:45:25 UTC, Gary Willoughby wrote:
On Sunday, 19 June 2016 at 10:35:59 UTC, Gary Willoughby wrote:
...
A more correct example:
In the second example, the problem is this:
alias Type = Unqual!(T);
You are declaring the function to return T, which in your
On Sunday, 19 June 2016 at 10:35:59 UTC, Gary Willoughby wrote:
...
A more correct example:
import core.stdc.stdlib;
import std.traits;
ref T foo(T)()
{
alias Type = Unqual!(T);
Type* foo = cast(Type*) malloc(Type.sizeof * 8);
return *foo;
}
void main(string[]
In the following code, the `foo` function doesn't work when
casting to an immutable or shared type. Can anyone please explain
what is happening here? Is there any way of returning such
variables byRef from a malloc'd chunk of memory?
import core.stdc.stdlib;
ref T foo(T)()
{
int* foo