bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error compiling code with auto_ptr


From: Tron Thomas
Subject: Error compiling code with auto_ptr
Date: Sat, 19 Apr 2003 13:59:29 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02

The following code, which is perfectly valid C++, fails to compile using the command "g++ -g -Wall -ansi -pedantic -c":

#include <memory>

typedef std::auto_ptr<int> IntPtr;

int main()
{
   IntPtr intPtr(NULL);

   intPtr = IntPtr(new int(0));

   return 0;
}

The error message is:

: In function `int main ()':
9: no match for `IntPtr & = IntPtr'
/usr/include/g++-3/memory:40: candidates are: auto_ptr<_Tp>
&auto_ptr<_Tp>::operator= (auto_ptr<_Tp> &) [with _Tp = int]
/usr/include/g++-3/memory:48:                 auto_ptr<_Tp>
&auto_ptr<_Tp>::operator= (auto_ptr<_Tp1> &) [with _Tp1 = int, _Tp =
int]

This problem was found on RedHat Linux 7.2 (Intel), using version 2.96 of the GNU compiler.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]