Bug 809931 - make Static{Auto,Ref}Ptr have trivial constructors and destructors; r=jlebar

This commit is contained in:
Nathan Froyd 2012-11-09 16:48:42 -05:00
parent e042b3ba4f
commit 93cadceec0

View File

@ -35,14 +35,15 @@ template<class T>
class StaticAutoPtr
{
public:
// In debug builds, check that mRawPtr is initialized for us as we expect
// by the compiler. In non-debug builds, don't declare a constructor
// so that the compiler can see that the constructor is trivial.
#ifdef DEBUG
StaticAutoPtr()
{
// In debug builds, check that mRawPtr is initialized for us as we expect
// by the compiler.
MOZ_ASSERT(!mRawPtr);
}
~StaticAutoPtr() {}
#endif
StaticAutoPtr<T>& operator=(T* rhs)
{
@ -72,8 +73,13 @@ class StaticAutoPtr
}
private:
// Disallow copy constructor.
// Disallow copy constructor, but only in debug mode. We only define
// a default constructor in debug mode (see above); if we declared
// this constructor always, the compiler wouldn't generate a trivial
// default constructor for us in non-debug mode.
#ifdef DEBUG
StaticAutoPtr(StaticAutoPtr<T> &other);
#endif
void Assign(T* newPtr)
{
@ -90,14 +96,15 @@ template<class T>
class StaticRefPtr
{
public:
// In debug builds, check that mRawPtr is initialized for us as we expect
// by the compiler. In non-debug builds, don't declare a constructor
// so that the compiler can see that the constructor is trivial.
#ifdef DEBUG
StaticRefPtr()
{
MOZ_ASSERT(!mRawPtr);
}
~StaticRefPtr()
{
}
#endif
StaticRefPtr<T>& operator=(T* rhs)
{