Consider the following code:
#include <memory>
struct A {};
struct B : public A {};
void func( std::auto_ptr< A > ptr ) {}
int main() {
std::auto_ptr< B > b( new B() );
func( b );
}
I know that auto_ptr
is removed in C++17 and was deprecated for a long time, however, I am using boost-python, which does not support unique_ptr
in its interfaces (e.g., see this). I am using g++ 7.5.
Due to the conversion constructor defined by auto_ptr
(see (3)), implicit conversion should be possible. However, I get the error:
error: conversion from ‘std::auto_ptr’ to ‘std::auto_ptr’ is ambiguous
If I use unique_ptr
instead, which defines a similar constructor (see (6)), I get a similar error:
error: could not convert ‘b’ from ‘std::unique_ptr’ to ‘std::unique_ptr’
Why is that?