GCC 4.4.1, C++0x and unique_ptr

Hello!

I'm playing with C++0x features introduced in GCC 4.4 for a while. I found interesting behavior (maybe bug?). I'd like to know your opinio, before I decide to report a bug.

I declared class with private destructor and constructor. I want to use auto_ptr to handle this class objects, so I had to declare auto_ptr class as a friend:

1
2
3
4
5
6
7
8
9
class AAA
{
    public:
        static void some_method (void);
        friend class std::unique_ptr <AAA>;
    private:
        AAA (void);
        ~AAA (void);
};


This code works fine I'm able to create 'std::auto_ptr <AAA>' objects, gcc doesn't complain.

But, when I change auto_ptr to unique_ptr gcc fails with error:
1
2
error: ‘virtual AAA::~AAA()’ is private
/usr/include/c++/4.4/bits/unique_ptr.h:64: error: within this context


What do you think about that?
I believe the problem might be your friend declaration.

Did you try

template<> friend class std::unique_ptr<AAA>;

(I don't remember if friend goes before or after template<>).

Both declarations

template<> friend class std::unique_ptr<AAA>;

and

friend template<> class std::unique_ptr<AAA>;

fails
Topic archived. No new replies allowed.