January 09, 2002 non-const reference to temporary | ||||
---|---|---|---|---|
| ||||
Hi, this one was recently discussed on comp.lang.c++.moderated (a non-const reference shouldn't be allowed to be bound to a temporary): #include <stdio.h> struct A { }; int f(const A &a) { printf("f(const A &)\n"); return 0; } int f(A &a) { printf("f(A &)\n"); return 1; } int main(int argc, char *argv[]) { return f(A()); } But DM calls f(A &) instead of f(const A &). bye, Christof |
January 10, 2002 Re: non-const reference to temporary | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | Ok, I've got them logged! -Walter "Christof Meerwald" <cmeerw@web.de> wrote in message news:a1hu2k$1hkn$2@digitaldaemon.com... > Hi, > > this one was recently discussed on comp.lang.c++.moderated (a non-const reference shouldn't be allowed to be bound to a temporary): > > #include <stdio.h> > > struct A > { }; > > int f(const A &a) > { > printf("f(const A &)\n"); > return 0; > } > > int f(A &a) > { > printf("f(A &)\n"); > return 1; > } > > int main(int argc, char *argv[]) > { > return f(A()); > } > > > But DM calls f(A &) instead of f(const A &). > > > bye, Christof |
Copyright © 1999-2021 by the D Language Foundation