Re: Access to operator delete of a private nested class
On May 31, 9:28 am, Alberto Ganesh Barbati <AlbertoBarb...@libero.it>
wrote:
They aren't. And even if they were, you don't need to know much of the
shared_ptr<> internals to provide a custom deleter. Consider this:
Unfortunately, in our application we heavily use explicit loading and
unloading of modules (DLLs) and this is not compatible with C++
virtual template mebers (and virtual inline functions) as vtbl gets
initialized with addresses inside a module which is then unloaded
(boom!). We use our own shared_ptr<> with removed support of deleters
and with no virtual functions inside.
This means that we are in control of a name of template function which
specialization should be declared a friend of an outer class A to
workaround the problem in MS VC.
I kindly ask everybody who beleives that the code below should compile
to vote for it here:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=349189
#include <cstdlib>
#include <memory>
class A
{
private:
class B
{
public:
void test()
{
std::tr1::shared_ptr<B>(new B());
}
~B()
{
}
void* operator new(size_t size)
{
return std::malloc(size);
}
void operator delete(void* p, size_t /*size*/)
{
std::free(p);
}
};
};
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]