On Saturday, 24 November 2012 at 20:34:39 UTC, comco wrote:
I have the following snippet:
struct A(alias Method)
{
string s;
this(Method method) {
method(s); // 5
}
}
struct B
{
this(int i) { }
void opCall(string s) { }
}
void main() {
A!B(B(0));
}
This code
On Saturday, 24 November 2012 at 22:01:32 UTC, Stian wrote:
Is the compiler sophisticated enough that is it able to avoid
the copying. For instance, if i have a struct Matrix4x4 a =
node.getTransformation() and use a for whatever, but never
alter it, will it be able to avoid the copy? What if i
On Saturday, 24 November 2012 at 20:47:17 UTC, Era Scarecrow
wrote:
This kind of behavior *really* needs to be documented in
precise detail, it's rather critical to know.
It IS documented. TDPL - pg. 248
[quote]
Thanks for pointing out where the postblit stuff is documented.
When I first st
On Saturday, 24 November 2012 at 20:47:17 UTC, Era Scarecrow
wrote:
On Friday, 23 November 2012 at 22:31:46 UTC, Rob T wrote:
That's VERY interesting indeed and originally I had no idea it
would do this without a custom opAssign at each level.
This kind of behavior *really* needs to be documen
On Saturday, 24 November 2012 at 22:01:32 UTC, Stian wrote:
After reading that a couple of times it is a bit clearer, thank
you. I need to wrap my head around this. I am working on a
simple render/game engine, where, of course, vectors and
matrices are flying around.
Is the compiler sophistic
After reading that a couple of times it is a bit clearer, thank
you. I need to wrap my head around this. I am working on a simple
render/game engine, where, of course, vectors and matrices are
flying around.
Is the compiler sophisticated enough that is it able to avoid the
copying. For instan
On Saturday, November 24, 2012 21:46:41 Stian wrote:
> Okay, Im trying to wrap my head around how i can return a
> reference from a class.
> Lets say I have some class Foo that stores a struct Bar that
> stores many bytes.
>
> In C, i would have a function
>
> const Bar & getBar(){return bar;}
>
On Friday, 23 November 2012 at 22:31:46 UTC, Rob T wrote:
That's VERY interesting indeed and originally I had no idea it
would do this without a custom opAssign at each level.
This kind of behavior *really* needs to be documented in
precise detail, it's rather critical to know.
It IS docume
Okay, Im trying to wrap my head around how i can return a
reference from a class.
Lets say I have some class Foo that stores a struct Bar that
stores many bytes.
In C, i would have a function
const Bar & getBar(){return bar;}
In code, i could get a (const) reference to bar using
const Bar & v
I have the following snippet:
struct A(alias Method)
{
string s;
this(Method method) {
method(s); // 5
}
}
struct B
{
this(int i) { }
void opCall(string s) { }
}
void main() {
A!B(B(0));
}
This code fails to compile with the following errors:
test.d(5): Error:
On 11/24/12 12:30, Philippe Sigaud wrote:
>
> Unfortunately the is-expressions don't handle aliases properly, at least
> with my old compiler here. So this does not work:
>
>template isTempInst(alias TEMPL, T) {
> static if (is(T _ == TEMPL!CT, CT))
> enum i
On Sat, Nov 24, 2012 at 11:30 AM, Artur Skawina wrote:
> On 11/24/12 08:27, Philippe Sigaud wrote:
> > What's even nicer with an is() expr is that the introspection info is
> accessible when used inside a static if. So with Artur's code, CT can be
> seen inside the true branch of the static if.
>
On 11/24/12 08:27, Philippe Sigaud wrote:
> What's even nicer with an is() expr is that the introspection info is
> accessible when used inside a static if. So with Artur's code, CT can be seen
> inside the true branch of the static if.
Actually, static-ifs do not create a scope, so 'CT' leaks a
On Saturday, November 24, 2012 02:11:23 Jonathan M Davis wrote:
> On Saturday, November 24, 2012 10:59:24 Jack Applegame wrote:
> > struct Foo {
> >
> >int a;
> >
> > }
> > void modify(ref Foo foo) {
> >
> >foo.a++;
> >
> > }
> > void main() {
> >
> >modify(Foo(1));
> >
> > }
> >
On Saturday, November 24, 2012 10:59:24 Jack Applegame wrote:
> struct Foo {
>int a;
> }
> void modify(ref Foo foo) {
>foo.a++;
> }
> void main() {
>modify(Foo(1));
> }
>
> Why compiler doesn't report error? So as struct literal "Foo()"
> isn't a lvalue, it's impossible to pass it by r
struct Foo {
int a;
}
void modify(ref Foo foo) {
foo.a++;
}
void main() {
modify(Foo(1));
}
Why compiler doesn't report error? So as struct literal "Foo()"
isn't a lvalue, it's impossible to pass it by reference. Isn't it?
Just like string or numeric literals.
16 matches
Mail list logo