What I want to do is this:
#include <memory>
class autostr : public std::auto_ptr<char>
{
public:
autostr(char *a) : std::auto_ptr<char>(a) {}
autostr(autostr &a) : std::auto_ptr<char>(a) {}
// define a bunch of string utils here...
};
autostr test(char a)
{
return autostr(new char(a));
}
void main(int args, char **arg)
{
autostr asd = test('b');
return 0;
}
(I actually have a copy of the auto_ptr class that handles arrays as well, but the same error applies to the stl one)
The compile error using GCC 4.3.0 is:
main.cpp:152: error: no matching function for call to `autostr::autostr(autostr)' main.cpp:147: note: candidates are: autostr::autostr(autostr&) main.cpp:146: note: autostr::autostr(char*)
I don't understand why it's not matching the autostr argument as a valid parameter to autostr(autostr&).