This code compiles fine:
struct Vector(T, uint SIZE)
{
T[SIZE] vector;
this(T value) {
foreach (ref v; vector) v = value;
}
}
alias Vector!(int, 3) Vec3i;
but if I add a variadic constructor:
struct Vector(T, uint SI
Aw
Hello D world, I have just started using templates and mixins to
generate some boilerplate code and I have found a little
ambiguity:
This code compiles fine:
private template genTypes()
{
string eval() { ... }
const(char[]) genTypes = eval();
}
mixin(genTypes!()); // Working
Thanks to both of you !
Hi, I'm working with the X11 library available from
https://github.com/D-Programming-Deimos/libX11
If I try to call XSynchronize(display, True) the compilation
fails with "Error: function deimos.X11.Xlib.XSynchronize
(_XDisplay*) is not callable using argument types (_XDisplay*,
int)"
I am su
On Tuesday, 6 August 2013 at 08:21:26 UTC, bearophile wrote:
Try extern(C)?
It's not a linkage error, it's a syntax one
@Ali Çehreli
Thank you for the explanation. I'll send a pull request to fix
Xlib.d
Hi, I have written a function to convert a C string to a D string.
I did not use to!string because it allocates a new string while
what I want is a dynamic array of type char[] pointing to the C
string.
auto cstr2dstr(inout(char)* cstr)
{
import core.stdc.string: strlen;
return cstr ?
I hadn't tought of thath, thank you for the example.
Excellent discovery !
Remove the "ref" in "ref A opAdd(const ref A a) {"
Running this code I would expect to get "ref" three times, but ...
---
import std.stdio;
struct A {
int[128] data;
ref A opAdd(const ref A a) {
A cp = this;
cp.data[] += a.data[];
return cp;
}
}
void fun(A a) { writeln("
On Friday, 20 September 2013 at 09:44:51 UTC, Namespace wrote:
This prints 'ref' if you change func(A a) to func(const A a)
the match of const ref isn't prefered over A a because const
need an implicit conversion.
Thanks for the tip.
a + b is an rvalue and will moved to func(A a). This is eve
Output:
CTor A with 42
CTor A with 23
CTor A with 65
Value call with A::65
DTor A with 65
CTor A with 1337
Value call with A::1337
DTor A with 1337
Ref call with A::42
DTor A with 23
DTor A with 42
No Postblit call.
The beahvior is correct but at assembly level the compiler still
cre
I think that I found a bug in the initialization of a struct.
This program throws "a.v.y != 0" but all assert should pass...
(I'm using the latest dmd version available)
Code: http://pastebin.com/VHQP8DaE
Thanks for the answer, I will use the aliases; however I just
tried my code on codepad and surprising it worked without errors
http://codepad.org/hp0YxIi7
Added to bugzilla
http://d.puremagic.com/issues/show_bug.cgi?id=11147
Hi everyone,
I was trying to get my vector struct to use extensively
references for passing parameters and I found a subtle bug which
make me lose a few hour.
A sample code that shows the bug is here
http://pastebin.com/rvcNdjAE (fails with dmd 2.064 on linux)
I think that the code is wrong
18 matches
Mail list logo