-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello Matt,
Matt Hoosier a écrit :
> Hi,
>
> I'm having trouble compiling the following with g++ 4.2.1:
>
> class Uncopyable
> {
> public:
> Uncopyable(int x) {}
> private:
> Uncopyable(const Uncopyable & other) {}
> };
>
> class User
> {
> public:
> void foo(int x)
> {
> foo(Uncopyable(x));
> }
>
> void foo(const Uncopyable & x)
> {
> // do something
> }
> };
>
> int main ()
> {
> User u;
> u.foo(1);
> return 0;
> }
>
> The compiler complains that it can't find a copy ctor for
> 'Noncopyable'; why is this? It would seem that temporaries can be
> passed directly as the const ref rather than needing a copy.
>
I believe you are hitting a variant of this bug
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25950. It was fixed in gcc 4.3.0.
D.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Remi - http://enigmail.mozdev.org
iEYEARECAAYFAknea2YACgkQPejI7lrem2E6nwCeOTl70WVCPDxe3ikxw8JizDPo
Bn0Anjcs1qYmXgxMq3pUU99fn/oLKAvB
=tibw
-----END PGP SIGNATURE-----