www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - non-const reference to temporary

↑ ↓ ← Christof Meerwald <cmeerw web.de> writes:
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
Jan 09 2002
↑ ↓ → "Walter" <walter digitalmars.com> writes:
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

Jan 09 2002