This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/46910] New: std::shared_ptr requires public destructor for a class with friend deleter


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46910

           Summary: std::shared_ptr requires public destructor for a class
                    with friend deleter
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gccbugzilla@virginmedia.com


Created attachment 22726
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22726
Code example and compiler output

class TestA
{
public:
  static std::shared_ptr<TestA> CreateTestA();

private:
  TestA();
  ~TestA();

private:
  class Deleter;
  friend class Deleter;

};

class TestA::Deleter
{
public:
  void operator()( TestA * p)
  {
    std::cout << "Deleting TestA\n";
    delete p;
  }
};

std::shared_ptr<TestA> TestA::CreateTestA()
{
  return std::shared_ptr<TestA>(
                                new TestA(),
                                TestA::Deleter()
                                );
}
will not compile:
error: âTestA::~TestA()â is private

The boost shared_ptr works OK.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]