I was taking a look at /usr/include/gcc/darwin/4.0/c++/memory and I
noticed this comment:
/**
* @brief Automatic conversions
*
* These operations convert an %auto_ptr into and from an
auto_ptr_ref
* automatically as needed. This allows constructs such as
* @code
* auto_ptr<Derived> func_returning_auto_ptr(.....);
* ...
* auto_ptr<Base> ptr = func_returning_auto_ptr(.....);
* @endcode
*/
I decided to give it a try:
$ cat auto_ptr_test.cpp
#include <memory>
int main()
{
std::auto_ptr<foo> ptr = get_bar();
std::auto_ptr<foo> ptr2(get_bar());
return 0;
}
$ g++ -Wall auto_ptr_test.cpp
auto_ptr_test.cpp: In function 'int main()':
auto_ptr_test.cpp:10: error: no matching function for call to
'std::auto_ptr<foo>::auto_ptr(std::auto_ptr<foo>)'
/usr/include/gcc/darwin/4.0/c++/memory:349: note: candidates are:
std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr_ref<_Tp>) [with _Tp = foo]
/usr/include/gcc/darwin/4.0/c++/memory:212: note:
std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp1>&) [with _Tp1 = foo,
_Tp = foo]
/usr/include/gcc/darwin/4.0/c++/memory:199: note:
std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp>&) [with _Tp = foo]
auto_ptr_test.cpp:10: error: initializing temporary from result of
'std::auto_ptr<_Tp>::operator std::auto_ptr<_Tp1>() [with _Tp1 = foo,
_Tp = bar]'
However, if I comment out the
std::auto_ptr<foo> ptr = get_bar();
line, it compiles.
Am I doing something incorrectly here or is there a bug in g++ or is
the header file simply wrong? (Or a combination of the above?)
It looks like the third candidate:
std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp>&) [with _Tp = foo]
should match
std::auto_ptr<foo>::auto_ptr(std::auto_ptr<foo>)
but for some reason, it isn't.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden
This email sent to email@hidden