Index: /trunk/include/VBox/com/ErrorInfo.h
===================================================================
--- /trunk/include/VBox/com/ErrorInfo.h	(revision 30680)
+++ /trunk/include/VBox/com/ErrorInfo.h	(revision 30681)
@@ -32,6 +32,4 @@
 #include "VBox/com/Guid.h"
 #include "VBox/com/assert.h"
-
-#include <iprt/memory> // for auto_copy_ptr
 
 struct IProgress;
@@ -109,55 +107,20 @@
      */
     explicit ErrorInfo()
-        : mIsBasicAvailable (false), mIsFullAvailable (false)
-        , mResultCode (S_OK)
-        { init(); }
-
-    /**
-     *  Constructs a new, "interfaceless" ErrorInfo instance that takes
-     *  the error information possibly set on the current thread by an
-     *  interface method of the given interface pointer.
-
-     *  If the given interface does not support providing error information or,
-     *  for some reason didn't set any error information, both
-     *  #isFullAvailable() and #isBasicAvailable() will return |false|.
-     *
-     *  @param aPtr pointer to the interface whose method returned an
-     *              error
-     */
-    template <class I> ErrorInfo (I *aPtr)
-        : mIsBasicAvailable (false), mIsFullAvailable (false)
-        , mResultCode (S_OK)
-        { init (aPtr, COM_IIDOF(I)); }
-
-    /**
-     *  Constructs a new ErrorInfo instance from the smart interface pointer.
-     *  See template <class I> ErrorInfo (I *aPtr) for details
-     *
-     *  @param aPtr smart pointer to the interface whose method returned
-     *              an error
-     */
-    template <class I> ErrorInfo (const ComPtr <I> &aPtr)
-        : mIsBasicAvailable (false), mIsFullAvailable (false)
-        , mResultCode (S_OK)
-        { init (static_cast <I*> (aPtr), COM_IIDOF(I)); }
-
-    /** Specialization for the IVirtualBoxErrorInfo smart pointer */
-    ErrorInfo (const ComPtr <IVirtualBoxErrorInfo> &aPtr)
-        : mIsBasicAvailable (false), mIsFullAvailable (false)
-        , mResultCode (S_OK)
-        { init (aPtr); }
-
-    /**
-     *  Constructs a new ErrorInfo instance from the IVirtualBoxErrorInfo
-     *  interface pointer. If this pointer is not NULL, both #isFullAvailable()
-     *  and #isBasicAvailable() will return |true|.
-     *
-     *  @param aInfo    pointer to the IVirtualBoxErrorInfo interface that
-     *                  holds error info to be fetched by this instance
-     */
-    ErrorInfo (IVirtualBoxErrorInfo *aInfo)
-        : mIsBasicAvailable (false), mIsFullAvailable (false)
-        , mResultCode (S_OK)
-        { init (aInfo); }
+        : mIsBasicAvailable(false),
+          mIsFullAvailable(false),
+          mResultCode(S_OK),
+          m_pNext(NULL)
+    {
+        init();
+    }
+
+    ErrorInfo(IUnknown *pObj, const GUID &aIID)
+        : mIsBasicAvailable(false),
+          mIsFullAvailable(false),
+          mResultCode(S_OK),
+          m_pNext(NULL)
+    {
+        init(pObj, aIID);
+    }
 
     virtual ~ErrorInfo();
@@ -175,5 +138,8 @@
      *  this method returns true (otherwise they simply return NULL-like values).
      */
-    bool isBasicAvailable() const { return mIsBasicAvailable; }
+    bool isBasicAvailable() const
+    {
+        return mIsBasicAvailable;
+    }
 
     /**
@@ -189,41 +155,56 @@
      *  this method returns true (otherwise they simply return NULL-like values).
      */
-    bool isFullAvailable() const { return mIsFullAvailable; }
-
-    /**
-     *  Returns @c true if both isBasicAvailable() and isFullAvailable() are
-     *  @c false.
-     */
-    bool isNull() const { return !mIsBasicAvailable && !mIsFullAvailable; }
+    bool isFullAvailable() const
+    {
+        return mIsFullAvailable;
+    }
 
     /**
      *  Returns the COM result code of the failed operation.
      */
-    HRESULT getResultCode() const { return mResultCode; }
+    HRESULT getResultCode() const
+    {
+        return mResultCode;
+    }
 
     /**
      *  Returns the IID of the interface that defined the error.
      */
-    const Guid &getInterfaceID() const { return mInterfaceID; }
+    const Guid& getInterfaceID() const
+    {
+        return mInterfaceID;
+    }
 
     /**
      *  Returns the name of the component that generated the error.
      */
-    const Bstr &getComponent() const { return mComponent; }
+    const Bstr& getComponent() const
+    {
+        return mComponent;
+    }
 
     /**
      *  Returns the textual description of the error.
      */
-    const Bstr &getText() const { return mText; }
+    const Bstr& getText() const
+    {
+        return mText;
+    }
 
     /**
      *  Returns the next error information object or @c NULL if there is none.
      */
-    const ErrorInfo *getNext() const { return mNext.get(); }
+    const ErrorInfo* getNext() const
+    {
+        return m_pNext;
+    }
 
     /**
      *  Returns the name of the interface that defined the error
      */
-    const Bstr &getInterfaceName() const { return mInterfaceName; }
+    const Bstr& getInterfaceName() const
+    {
+        return mInterfaceName;
+    }
 
     /**
@@ -234,5 +215,8 @@
      *  template <class I> ErrorInfo (const ComPtr <I> &i) constructor.
      */
-    const Guid &getCalleeIID() const { return mCalleeIID; }
+    const Guid& getCalleeIID() const
+    {
+        return mCalleeIID;
+    }
 
     /**
@@ -243,5 +227,8 @@
      *  template <class I> ErrorInfo (const ComPtr <I> &i) constructor.
      */
-    const Bstr &getCalleeName() const { return mCalleeName; }
+    const Bstr& getCalleeName() const
+    {
+        return mCalleeName;
+    }
 
     /**
@@ -253,4 +240,10 @@
         mIsBasicAvailable = false;
         mIsFullAvailable = false;
+
+        if (m_pNext)
+        {
+            delete m_pNext;
+            m_pNext = NULL;
+        }
 
         mResultCode = S_OK;
@@ -258,5 +251,4 @@
         mComponent.setNull();
         mText.setNull();
-        mNext.reset();
         mInterfaceName.setNull();
         mCalleeIID.clear();
@@ -267,12 +259,14 @@
 protected:
 
-    ErrorInfo (bool /* aDummy */)
-        : mIsBasicAvailable (false), mIsFullAvailable (false)
-        , mResultCode (S_OK)
-        {}
-
-    void init (bool aKeepObj = false);
-    void init (IUnknown *aUnk, const GUID &aIID, bool aKeepObj = false);
-    void init (IVirtualBoxErrorInfo *aInfo);
+    ErrorInfo(bool /* aDummy */)
+        : mIsBasicAvailable(false),
+          mIsFullAvailable(false),
+          mResultCode(S_OK),
+          m_pNext(NULL)
+    { }
+
+    void init(bool aKeepObj = false);
+    void init(IUnknown *aUnk, const GUID &aIID, bool aKeepObj = false);
+    void init(IVirtualBoxErrorInfo *aInfo);
 
     bool mIsBasicAvailable : 1;
@@ -284,5 +278,5 @@
     Bstr    mText;
 
-    cppx::auto_copy_ptr <ErrorInfo> mNext;
+    ErrorInfo *m_pNext;
 
     Bstr mInterfaceName;
@@ -290,5 +284,8 @@
     Bstr mCalleeName;
 
-    ComPtr <IUnknown> mErrorInfo;
+    ComPtr<IUnknown> mErrorInfo;
+
+private:
+    ErrorInfo(const ErrorInfo&);
 };
 
@@ -311,5 +308,5 @@
      *  @param  progress    the progress object representing a failed operation
      */
-    ProgressErrorInfo (IProgress *progress);
+    ProgressErrorInfo(IProgress *progress);
 };
 
@@ -381,5 +378,5 @@
         setNull();
         mForgot = false;
-        init (true /* aKeepObj */);
+        init(true /* aKeepObj */);
     }
 
Index: /trunk/include/VBox/com/Guid.h
===================================================================
--- /trunk/include/VBox/com/Guid.h	(revision 30680)
+++ /trunk/include/VBox/com/Guid.h	(revision 30681)
@@ -44,5 +44,4 @@
 #include "VBox/com/string.h"
 
-#include <iprt/cpp/utils.h>
 #include <iprt/uuid.h>
 
Index: /trunk/include/VBox/com/array.h
===================================================================
--- /trunk/include/VBox/com/array.h	(revision 30680)
+++ /trunk/include/VBox/com/array.h	(revision 30681)
@@ -168,6 +168,4 @@
 #include "VBox/com/ptr.h"
 #include "VBox/com/assert.h"
-
-#include "iprt/cpp/utils.h"
 
 #if defined (VBOX_WITH_XPCOM)
Index: /trunk/include/VBox/com/com.h
===================================================================
--- /trunk/include/VBox/com/com.h	(revision 30680)
+++ /trunk/include/VBox/com/com.h	(revision 30681)
@@ -59,23 +59,4 @@
 void GetInterfaceNameByIID(const GUID &aIID, BSTR *aName);
 
-#ifdef VBOX_WITH_XPCOM
-
-/**
- *  Helper method to keep all the XPCOM headers out of include/VBox/com/ptr.h.
- */
-HRESULT GlueCreateObjectOnServer(const CLSID &clsid,
-                                 const char *serverName,
-                                 const nsIID &id,
-                                 void** ppobj);
-
-/**
- *  Helper method to keep all the XPCOM headers out of include/VBox/com/ptr.h.
- */
-HRESULT GlueCreateInstance(const CLSID &clsid,
-                           const nsIID &id,
-                           void** ppobj);
-
-#endif // VBOX_WITH_XPCOM
-
 /**
  *  Returns the VirtualBox user home directory.
Index: /trunk/include/VBox/com/defs.h
===================================================================
--- /trunk/include/VBox/com/defs.h	(revision 30680)
+++ /trunk/include/VBox/com/defs.h	(revision 30681)
@@ -521,60 +521,4 @@
         if ((FAILED (aRC) && !FAILED (mRC)) ||
             (mRC == S_OK && aRC != S_OK))
-            mRC = aRC;
-
-        return *this;
-    }
-
-    operator HRESULT() const { return mRC; }
-
-    HRESULT *operator&() { return &mRC; }
-
-private:
-
-    HRESULT mRC;
-};
-
-/**
- * "Last worst" result type.
- *
- * Variables of this class are used instead of HRESULT variables when it is
- * desirable to memorize the "last worst" result code instead of the last
- * assigned one. In other words, an assignment operation to a variable of this
- * class will succeed only if the result code to assign has the same or worse
- * severity. The following table demonstrate this (the first column lists the
- * previous result code stored in the variable, the first row lists the new
- * assigned, 'A' means the assignment will take place, '> S_OK' means a warning
- * result code):
- *
- * {{{
- *             FAILED    > S_OK    S_OK
- * FAILED        A         -         -
- * > S_OK        A         A         -
- * S_OK          A         A         -
- *
- * }}}
- *
- * In practice, you will need to use a LWResult variable when you call some COM
- * method B after COM method A fails and want to return the result code of B
- * if B also fails, but still want to return the failed result code of A if B
- * issues a warning or succeeds.
- */
-class LWResult
-{
-
-public:
-
-    /**
-     * Constructs a new variable. Note that by default this constructor sets the
-     * result code to E_FAIL to make sure a failure is returned to the caller if
-     * the variable is never assigned another value (which is considered as the
-     * improper use of this class).
-     */
-    LWResult (HRESULT aRC = E_FAIL) : mRC (aRC) {}
-
-    LWResult &operator= (HRESULT aRC)
-    {
-        if (FAILED (aRC) ||
-            (SUCCEEDED (mRC) && aRC != S_OK))
             mRC = aRC;
 
Index: /trunk/include/VBox/com/ptr.h
===================================================================
--- /trunk/include/VBox/com/ptr.h	(revision 30680)
+++ /trunk/include/VBox/com/ptr.h	(revision 30681)
@@ -43,7 +43,25 @@
 #else
  #include <nsISupportsUtils.h>
+
 #endif /* !defined (VBOX_WITH_XPCOM) */
 
-#include <VBox/com/com.h>
+#include <VBox/com/defs.h>
+
+#ifdef VBOX_WITH_XPCOM
+
+namespace com
+{
+// declare a couple of XPCOM helper methods (defined in glue/com.cpp)
+// so we don't have to include a ton of XPCOM implementation headers here
+HRESULT GlueCreateObjectOnServer(const CLSID &clsid,
+                                 const char *serverName,
+                                 const nsIID &id,
+                                 void** ppobj);
+HRESULT GlueCreateInstance(const CLSID &clsid,
+                           const nsIID &id,
+                           void** ppobj);
+}
+
+#endif // VBOX_WITH_XPCOM
 
 /**
Index: /trunk/include/iprt/cpp/utils.h
===================================================================
--- /trunk/include/iprt/cpp/utils.h	(revision 30680)
+++ /trunk/include/iprt/cpp/utils.h	(revision 30681)
@@ -27,8 +27,4 @@
 #define ___iprt_cpputils_h
 
-#include <iprt/assert.h>
-
-#include <memory>
-
 /** @defgroup grp_rt_cpputils   C++ Utilities
  * @ingroup grp_rt
@@ -48,5 +44,5 @@
  */
 template <class C>
-inline C &unconst (const C &that) { return const_cast <C &> (that); }
+inline C& unconst(const C &that) { return const_cast<C&>(that); }
 
 
@@ -63,335 +59,9 @@
  */
 template <class C>
-inline C *unconst (const C *that) { return const_cast <C *> (that); }
+inline C* unconst(const C *that) { return const_cast<C*>(that); }
 
 
-/**
- * Extensions to the std namespace.
- */
-namespace stdx
+namespace iprt
 {
-
-/* forward */
-template <class> class auto_ref_ptr;
-
-/**
- * Base class for objects willing to support smart reference counting using
- * the auto_ref_ptr template.
- *
- * When a class wants to be used with the auto_ref_ptr template it simply
- * declares the auto_ref class among its public base classes -- there is no
- * need to implement any additional methods.
- */
-class auto_ref
-{
-protected:
-
-    auto_ref() : mRefs (0) {}
-
-    /** Increases the reference counter and returns it */
-    size_t ref() { return ++ mRefs; }
-
-    /** Decreases the reference counter and returns it */
-    size_t unref() { Assert (mRefs > 0); return -- mRefs; }
-
-private:
-
-    size_t mRefs;
-
-    template <class> friend class auto_ref_ptr;
-};
-
-/**
- * The auto_ref_ptr template manages pointers to objects that support
- * reference counting by implementing auto_ref or a similar interface.
- *
- * Pointer management includes the following key points:
- *
- *   1) Automatic increment of the object's reference counter when the given
- *      auto_ref_ptr instance starts managing a pointer to this object.
- *
- *   2) Automatic decrement of the reference counter when the given
- *      auto_ref_ptr instance is destroyed, or before it is assigned a pointer
- *      to a new object.
- *
- *   3) Automatic deletion of the managed object whenever its reference
- *      counter reaches zero after a decrement.
- *
- *   4) Providing the dereference operator-> that gives direct access to the
- *      managed pointer.
- *
- * The object class to manage must provide ref() and unref() methods that have
- * the same syntax and semantics as defined in the auto_ref class.
- *
- * @param C     Class to manage.
- */
-template <class C>
-class auto_ref_ptr
-{
-public:
-
-    /**
-     * Creates a null instance that does not manage anything.
-     */
-    auto_ref_ptr() : m (NULL) {}
-
-    /**
-     * Creates an instance that starts managing the given pointer. The
-     * reference counter of the object pointed to by @a a is incremented by
-     * one.
-     *
-     * @param a Pointer to manage.
-     */
-    auto_ref_ptr (C* a) : m (a) { if (m) m->ref(); }
-
-    /**
-     * Creates an instance that starts managing a pointer managed by the given
-     * instance. The reference counter of the object managed by @a that is
-     * incremented by one.
-     *
-     * @param that Instance to take a pointer to manage from.
-     */
-    auto_ref_ptr (const auto_ref_ptr &that) : m (that.m) { if (m) m->ref(); }
-
-    ~auto_ref_ptr() { do_unref(); }
-
-    /**
-     * Assigns the given pointer to this instance and starts managing it. The
-     * reference counter of the object pointed to by @a a is incremented by
-     * one. The reference counter of the object previously managed by this
-     * instance is decremented by one.
-     *
-     * @param a Pointer to assign.
-     */
-    auto_ref_ptr &operator= (C *a) { do_reref (a); return *this; }
-
-    /**
-     * Assigns a pointer managed by the given instance to this instance and
-     * starts managing it. The reference counter of the object managed by @a
-     * that is incremented by one. The reference counter of the object
-     * previously managed by this instance is decremented by one.
-     *
-     * @param that Instance which pointer to reference.
-     */
-    auto_ref_ptr &operator= (const auto_ref_ptr &that) { do_reref (that.m); return *this; }
-
-    /**
-     * Returns @c true if this instance is @c null and false otherwise.
-     */
-    bool is_null() const { return m == NULL; }
-
-    /**
-     * Dereferences the instance by returning the managed pointer.
-     * Asserts that the managed pointer is not @c NULL.
-     */
-    C *operator-> () const { AssertMsg (m, ("Managed pointer is NULL!\n")); return m; }
-
-    /**
-     * Returns the managed pointer or @c NULL if this instance is @c null.
-     */
-    C *raw() const { return m; }
-
-    /**
-     * Compares this auto_ref_ptr instance with another instance and returns
-     * @c true if both instances manage the same or @c NULL pointer.
-     *
-     * Note that this method compares pointer values only, it doesn't try to
-     * compare objects themselves. Doing otherwise would a) break the common
-     * 'pointer to something' comparison semantics auto_ref_ptr tries to
-     * follow and b) require to define the comparison operator in the managed
-     * class which is not always possible. You may analyze pointed objects
-     * yourself if you need more precise comparison.
-     *
-     * @param that Instance to compare this instance with.
-     */
-    bool operator== (const auto_ref_ptr &that) const
-    {
-        return m == that.m;
-    }
-
-protected:
-
-    void do_reref (C *a)
-    {
-        /* be aware of self assignment */
-        if (a)
-            a->ref();
-        if (m)
-        {
-            size_t refs = m->unref();
-            if (refs == 0)
-            {
-                refs = 1; /* stabilize */
-                delete m;
-            }
-        }
-        m = a;
-    }
-
-    void do_unref() { do_reref (NULL); }
-
-    C *m;
-};
-
-/**
- * The exception_trap_base class is an abstract base class for all
- * exception_trap template instantiations.
- *
- * Pointer variables of this class are used to store a pointer any object of
- * any class instantiated from the exception_trap template, or in other words
- * to store a full copy of any exception wrapped into the exception_trap instance
- * allocated on the heap.
- *
- * See the exception_trap template for more info.
- */
-class exception_trap_base
-{
-public:
-    virtual void rethrow() = 0;
-    virtual ~exception_trap_base() {}
-};
-
-/**
- * The exception_trap template acts like a wrapper for the given exception
- * class that stores a full copy of the exception and therefore allows to
- * rethrow it preserving the actual type information about the exception
- * class.
- *
- * This functionality is useful in situations where it is necessary to catch a
- * (known) number of exception classes and pass the caught exception instance
- * to an upper level using a regular variable (rather than the exception
- * unwinding mechanism itself) *and* preserve all information about the type
- * (class) of the caight exception so that it may be rethrown on the upper
- * level unchanged.
- *
- * Usage pattern:
- * @code
-    using namespace std;
-    using namespace stdx;
-
-    auto_ptr <exception_trap_base> trapped;
-
-    int callback();
-
-    int safe_callback()
-    {
-      try
-      {
-        // callback may throw a set of exceptions but we don't want it to start
-        // unwinding the stack right now
-
-        return callback();
-      }
-      catch (const MyException &err) { trapped = new_exception_trap (err); }
-      catch (const MyException2 &err) { trapped = new_exception_trap (err); }
-      catch (...) { trapped = new_exception_trap (logic_error()); }
-
-      return -1;
-    }
-
-    void bar()
-    {
-      // call a funciton from some C library that supports callbacks but knows
-      // nothing about exceptions so throwing one from a callback will leave
-      // the library in an undetermined state
-
-      do_something_with_callback (safe_callback());
-
-      // check if we have got an exeption from callback() and rethrow it now
-      // when we are not in the C library any more
-      if (trapped.get() != NULL)
-        trapped->rethrow();
-    }
- * @endcode
- *
- * @param T Exception class to wrap.
- */
-template <typename T>
-class exception_trap : public exception_trap_base
-{
-public:
-
-    exception_trap (const T &aTrapped) : trapped (aTrapped) {}
-    void rethrow() { throw trapped; }
-
-    T trapped;
-};
-
-/**
- * Convenience function that allocates a new exception_trap instance on the
- * heap by automatically deducing the exception_trap template argument from
- * the type of the exception passed in @a aTrapped.
- *
- * The following two lines of code inside the catch block are equivalent:
- *
- * @code
-    using namespace std;
-    using namespace stdx;
-    catch (const MyException &err)
-    {
-      auto_ptr <exception_trap_base> t1 = new exception_trap <MyException> (err);
-      auto_ptr <exception_trap_base> t2 = new_exception_trap (err);
-    }
- * @endcode
- *
- * @param aTrapped Exception to put to the allocated trap.
- *
- * @return Allocated exception_trap object.
- */
-template <typename T>
-static exception_trap <T> *
-new_exception_trap (const T &aTrapped)
-{
-    return new exception_trap <T> (aTrapped);
-}
-
-/**
- * Enhancement of std::auto_ptr @<char@> intended to take pointers to char
- * buffers allocated using new[].
- *
- * This differs from std::auto_ptr @<char@> so that it overloads some methods to
- * uses delete[] instead of delete to delete the owned data in order to
- * conform to the C++ standard (and avoid valgrind complaints).
- *
- * Note that you should not use instances of this class where pointers or
- * references to objects of std::auto_ptr @<char@> are expeced. Despite the fact
- * the classes are related, the base is not polymorphic (in particular,
- * neither the destructor nor the reset() method are virtual). It means that when
- * acessing instances of this class through the base pointer, overloaded
- * methods won't be called.
- */
-class char_auto_ptr : public std::auto_ptr <char>
-{
-public:
-
-    explicit char_auto_ptr (char *a = 0) throw()
-        : std::auto_ptr <char> (a) {}
-
-    /* Note: we use unconst brute force below because the non-const version
-     * of the copy constructor won't accept temporary const objects
-     * (e.g. function return values) in GCC. std::auto_ptr has the same
-     * "problem" but it seems overcome it using #pragma GCC system_header
-     * which doesn't work here. */
-    char_auto_ptr (const char_auto_ptr &that) throw()
-        : std::auto_ptr <char> (unconst (that).release()) {}
-
-    ~char_auto_ptr() { delete[] (release()); }
-
-    char_auto_ptr &operator= (char_auto_ptr &that) throw()
-    {
-        std::auto_ptr <char>::operator= (that);
-        return *this;
-    }
-
-    void reset (char *a) throw()
-    {
-        if (a != get())
-        {
-            delete[] (release());
-            std::auto_ptr <char>::reset (a);
-        }
-    }
-};
-
 /**
  * A simple class used to prevent copying and assignment.  Inherit from this
@@ -409,8 +79,8 @@
 };
 
-} /* namespace stdx */
+} // namespace iprt
 
 /** @} */
 
-#endif
+#endif // ___iprt_cpputils_h
 
Index: /trunk/include/iprt/memory
===================================================================
--- /trunk/include/iprt/memory	(revision 30680)
+++ /trunk/include/iprt/memory	(revision 30681)
@@ -1,95 +1,0 @@
-/** @file
- * IPRT - C++ Extensions: memory.
- */
-
-/*
- * Copyright (C) 2007 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- *
- * The contents of this file may alternatively be used under the terms
- * of the Common Development and Distribution License Version 1.0
- * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
- * VirtualBox OSE distribution, in which case the provisions of the
- * CDDL are applicable instead of those of the GPL.
- *
- * You may elect to license modified versions of this file under the
- * terms and conditions of either the GPL or the CDDL or both.
- */
-
-#ifndef ___iprt_memory___
-#define ___iprt_memory___
-
-/** @defgroup grp_rt_cppx_memory  IPRT C++ Extensions: memory
- * @ingroup grp_rt_cppx
- * @{
- */
-
-#ifdef __cplusplus
-
-#include <memory> /* for auto_ptr */
-
-namespace cppx
-{
-
-/**
- *  A simple std::auto_ptr extension that adds CopyConstructible and
- *  Assignable semantics.
- *
- *  Instances of this class, when constructed from or assigned with instances
- *  of the same class, create a copy of the managed object using the new
- *  operator and the managed object's copy constructor, as opposed to
- *  std::auto_ptr which simply transfers ownership in these cases.
- *
- *  This template is useful for member variables of a class that store
- *  dynamically allocated instances of some other class and these instances
- *  need to be copied when the containing class instance is copied itself.
- *
- *  Be careful when returning instances of this class by value: it will call
- *  cause to create a copy of the managed object which is probably is not what
- *  you want, especially if its constructor is quite an expensive operation.
- */
-template <typename T>
-class auto_copy_ptr : public std::auto_ptr <T>
-{
-public:
-
-    /** @see std::auto_ptr <T>::auto_ptr() */
-    auto_copy_ptr (T *p = 0) throw() : std::auto_ptr <T> (p) {}
-
-    /**
-     * Copy constructor.
-     * Takes a copy of the given instance by taking a copy of the managed
-     * object using its copy constructor. Both instances will continue to own
-     * their objects.
-     */
-    auto_copy_ptr (const auto_copy_ptr &that) throw()
-        : std::auto_ptr <T> (that.get() ? new T (*that.get()) : NULL) {}
-
-    /**
-     * Assignment operator.
-     * Takes a copy of the given instance by taking a copy of the managed
-     * object using its copy constructor. Both instances will continue to own
-     * their objects.
-     */
-    auto_copy_ptr &operator= (const auto_copy_ptr &that) throw()
-    {
-        std::auto_ptr <T>::reset (that.get() ? new T (*that.get()) : NULL);
-        return *this;
-    }
-};
-
-} /* namespace cppx */
-
-
-#endif /* __cplusplus */
-
-/** @} */
-
-#endif
Index: /trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h	(revision 30680)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h	(revision 30681)
@@ -26,5 +26,5 @@
 /** A simple class describing a service.  VBoxClient will run exactly one
  * service per invocation. */
-class Service : public stdx::non_copyable
+class Service : public iprt::non_copyable
 {
 public:
Index: /trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp	(revision 30680)
+++ /trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp	(revision 30681)
@@ -139,8 +139,8 @@
             if (FAILED (resultCode))
             {
-                ComPtr <IVirtualBoxErrorInfo> errorInfo;
-                CHECK_ERROR_BREAK (progress,
-                                   COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
-                ErrorInfo info (errorInfo);
+                ComPtr<IVirtualBoxErrorInfo> errorInfo;
+                CHECK_ERROR_BREAK(progress,
+                                  COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
+                ErrorInfo info(errorInfo, COM_IIDOF(IVirtualBoxErrorInfo));
                 com::GluePrintErrorInfo(info);
             }
@@ -175,8 +175,8 @@
                 if (FAILED (resultCode))
                 {
-                    ComPtr <IVirtualBoxErrorInfo> errorInfo;
-                    CHECK_ERROR_BREAK (progress,
-                                       COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
-                    ErrorInfo info (errorInfo);
+                    ComPtr<IVirtualBoxErrorInfo> errorInfo;
+                    CHECK_ERROR_BREAK(progress,
+                                      COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
+                    ErrorInfo info(errorInfo, COM_IIDOF(IVirtualBoxErrorInfo));
                     com::GluePrintErrorInfo(info);
                 }
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 30680)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp	(revision 30681)
@@ -324,15 +324,11 @@
                 /* If we got a VBOX_E_IPRT error we handle the error in a more gentle way
                  * because it contains more accurate info about what went wrong. */
-                ErrorInfo info(guest);
+                ErrorInfo info(guest, COM_IIDOF(IGuest));
                 if (info.isFullAvailable())
                 {
                     if (rc == VBOX_E_IPRT_ERROR)
-                    {
                         RTPrintf("%ls.\n", info.getText().raw());
-                    }
                     else
-                    {
                         RTPrintf("ERROR: %ls (%Rhrc).\n", info.getText().raw(), info.getResultCode());
-                    }
                 }
                 break;
@@ -398,5 +394,5 @@
                             /* If we got a VBOX_E_IPRT error we handle the error in a more gentle way
                              * because it contains more accurate info about what went wrong. */
-                            ErrorInfo info(guest);
+                            ErrorInfo info(guest, COM_IIDOF(IGuest));
                             if (info.isFullAvailable())
                             {
@@ -493,5 +489,5 @@
                         ComPtr<IVirtualBoxErrorInfo> execError;
                         rc = progress->COMGETTER(ErrorInfo)(execError.asOutParam());
-                        com::ErrorInfo info (execError);
+                        com::ErrorInfo info(execError, COM_IIDOF(IVirtualBoxErrorInfo));
                         if (SUCCEEDED(rc) && info.isFullAvailable())
                         {
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp	(revision 30680)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp	(revision 30681)
@@ -267,5 +267,5 @@
         RTPrintf("Interpreting %ls...\n", path.raw());
         rc = pAppliance->Interpret();
-        com::ErrorInfo info0(pAppliance);
+        com::ErrorInfo info0(pAppliance, COM_IIDOF(IAppliance));
 
         com::SafeArray<BSTR> aWarnings;
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp	(revision 30680)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp	(revision 30681)
@@ -170,5 +170,5 @@
                 rc = machine->COMGETTER(AccessError)(accessError.asOutParam());
                 RTPrintf("Access error details:\n");
-                ErrorInfo ei(accessError);
+                ErrorInfo ei(accessError, COM_IIDOF(IVirtualBoxErrorInfo));
                 GluePrintErrorInfo(ei);
                 RTPrintf("\n");
@@ -1291,5 +1291,5 @@
             if (FAILED(rc))
             {
-                com::ErrorInfo info (display);
+                com::ErrorInfo info(display, COM_IIDOF(IDisplay));
                 GluePrintErrorInfo(info);
                 return rc;
@@ -1356,5 +1356,5 @@
                 if (FAILED(rc))
                 {
-                    com::ErrorInfo info (remoteDisplayInfo);
+                    com::ErrorInfo info(remoteDisplayInfo, COM_IIDOF(IRemoteDisplayInfo));
                     GluePrintErrorInfo(info);
                     return rc;
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 30680)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 30681)
@@ -387,7 +387,7 @@
         if (FAILED(iRc))
         {
-            ComPtr <IVirtualBoxErrorInfo> errorInfo;
+            ComPtr<IVirtualBoxErrorInfo> errorInfo;
             CHECK_ERROR_RET(progress, COMGETTER(ErrorInfo)(errorInfo.asOutParam()), 1);
-            ErrorInfo info (errorInfo);
+            ErrorInfo info(errorInfo, COM_IIDOF(IVirtualBoxErrorInfo));
             com::GluePrintErrorInfo(info);
         }
Index: /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 30680)
+++ /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 30681)
@@ -2008,5 +2008,5 @@
     if (rc != S_OK)
     {
-        com::ErrorInfo info(gConsole);
+        com::ErrorInfo info(gConsole, COM_IIDOF(IConsole));
         if (info.isBasicAvailable())
             PrintError("Failed to power up VM", info.getText().raw());
@@ -2792,5 +2792,5 @@
         for (unsigned i = 0; i < gcMonitors; i++)
             gDisplay->SetFramebuffer(i, NULL);
-    }    
+    }
 
     gMouse = NULL;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxMedium.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxMedium.h	(revision 30680)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxMedium.h	(revision 30681)
@@ -26,4 +26,6 @@
 /* Local includes */
 #include "COMDefs.h"
+
+#include <iprt/cpp/utils.h>
 
 /**
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.cpp	(revision 30680)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.cpp	(revision 30681)
@@ -224,5 +224,5 @@
 ////////////////////////////////////////////////////////////////////////////////
 
-void COMErrorInfo::init (const CVirtualBoxErrorInfo &info)
+void COMErrorInfo::init(const CVirtualBoxErrorInfo &info)
 {
     AssertReturnVoid (!info.isNull());
@@ -249,12 +249,13 @@
     gotAll &= info.isOk();
 
+    m_pNext = NULL;
+
     CVirtualBoxErrorInfo next = info.GetNext();
     if (info.isOk() && !next.isNull())
     {
-        mNext.reset (new COMErrorInfo (next));
-        Assert (mNext.get());
-    }
-    else
-        mNext.reset();
+        m_pNext = new COMErrorInfo(next);
+        Assert(m_pNext);
+    }
+
     gotSomething |= info.isOk();
     gotAll &= info.isOk();
@@ -266,4 +267,34 @@
 
     AssertMsg (gotSomething, ("Nothing to fetch!\n"));
+}
+
+void COMErrorInfo::copyFrom(const COMErrorInfo &x)
+{
+    mIsNull = x.mIsNull;
+    mIsBasicAvailable = x.mIsBasicAvailable;
+    mIsFullAvailable = x.mIsFullAvailable;
+
+    mResultCode = x.mResultCode;
+    mInterfaceID = x.mInterfaceID;
+    mComponent = x.mComponent;
+    mText = mText;
+
+    if (x.m_pNext)
+        m_pNext = new COMErrorInfo(*x.m_pNext);
+    else
+        m_pNext = NULL;
+
+    mInterfaceName = x.mInterfaceName;
+    mCalleeIID = x.mCalleeIID;
+    mCalleeName = x.mCalleeName;
+}
+
+void COMErrorInfo::cleanup()
+{
+    if (m_pNext)
+    {
+        delete m_pNext;
+        m_pNext = NULL;
+    }
 }
 
@@ -278,5 +309,5 @@
  *      UUID of the callee's interface. Ignored when callee is NULL
  */
-void COMErrorInfo::fetchFromCurrentThread (IUnknown *callee, const GUID *calleeIID)
+void COMErrorInfo::fetchFromCurrentThread(IUnknown *callee, const GUID *calleeIID)
 {
     mIsNull = true;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h	(revision 30680)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h	(revision 30681)
@@ -84,6 +84,4 @@
 #include <QMetaType>
 
-#include <iprt/memory> // for auto_copy_ptr
-
 /*
  * Additional COM / XPCOM defines and includes
@@ -123,11 +121,32 @@
 
     COMErrorInfo()
-        : mIsNull (true)
-        , mIsBasicAvailable (false), mIsFullAvailable (false)
-        , mResultCode (S_OK) {}
-
-    COMErrorInfo (const CVirtualBoxErrorInfo &info) { init (info); }
-
-    /* the default copy ctor and assignment op are ok */
+        : mIsNull(true),
+          mIsBasicAvailable(false),
+          mIsFullAvailable(false),
+          mResultCode(S_OK),
+          m_pNext(NULL)
+    {}
+
+    COMErrorInfo(const COMErrorInfo &info)
+    {
+        copyFrom(info);
+    }
+
+    COMErrorInfo(const CVirtualBoxErrorInfo &info)
+    {
+        init(info);
+    }
+
+    ~COMErrorInfo()
+    {
+        cleanup();
+    }
+
+    COMErrorInfo& operator=(const COMErrorInfo &info)
+    {
+        cleanup();
+        copyFrom(info);
+        return *this;
+    }
 
     bool isNull() const { return mIsNull; }
@@ -141,5 +160,5 @@
     QString text() const { return mText; }
 
-    const COMErrorInfo *next() const { return mNext.get(); }
+    const COMErrorInfo *next() const { return m_pNext; }
 
     QString interfaceName() const { return mInterfaceName; }
@@ -148,7 +167,9 @@
 
 private:
-
-    void init (const CVirtualBoxErrorInfo &info);
-    void fetchFromCurrentThread (IUnknown *callee, const GUID *calleeIID);
+    void init(const CVirtualBoxErrorInfo &info);
+    void copyFrom(const COMErrorInfo &x);
+    void cleanup();
+
+    void fetchFromCurrentThread(IUnknown *callee, const GUID *calleeIID);
 
     static QString getInterfaceNameFromIID (const QUuid &id);
@@ -163,5 +184,5 @@
     QString mText;
 
-    cppx::auto_copy_ptr <COMErrorInfo> mNext;
+    COMErrorInfo *m_pNext;
 
     QString mInterfaceName;
@@ -537,7 +558,8 @@
      * Queries the current result code and error info from the given component.
      */
-    COMResult (const COMBaseWithEI &aComponent)
-        : mRC (aComponent.lastRC())
-        , mErrInfo (aComponent.errorInfo()) {}
+    COMResult(const COMBaseWithEI &aComponent)
+        : mRC(aComponent.lastRC()),
+          mErrInfo(aComponent.errorInfo())
+    { }
 
     /**
Index: /trunk/src/VBox/HostServices/GuestControl/service.cpp
===================================================================
--- /trunk/src/VBox/HostServices/GuestControl/service.cpp	(revision 30680)
+++ /trunk/src/VBox/HostServices/GuestControl/service.cpp	(revision 30681)
@@ -147,5 +147,5 @@
  * Class containing the shared information service functionality.
  */
-class Service : public stdx::non_copyable
+class Service : public iprt::non_copyable
 {
 private:
@@ -718,6 +718,6 @@
         switch (eFunction)
         {
-            /* 
-             * The guest asks the host for the next messsage to process. 
+            /*
+             * The guest asks the host for the next messsage to process.
              */
             case GUEST_GET_HOST_MSG:
@@ -737,5 +737,5 @@
 
             /*
-             * The guest notifies the host that some output at stdout/stderr is available. 
+             * The guest notifies the host that some output at stdout/stderr is available.
              */
             case GUEST_EXEC_SEND_OUTPUT:
@@ -744,6 +744,6 @@
                 break;
 
-            /* 
-             * The guest notifies the host of the current client status. 
+            /*
+             * The guest notifies the host of the current client status.
              */
             case GUEST_EXEC_SEND_STATUS:
Index: /trunk/src/VBox/HostServices/GuestProperties/service.cpp
===================================================================
--- /trunk/src/VBox/HostServices/GuestProperties/service.cpp	(revision 30680)
+++ /trunk/src/VBox/HostServices/GuestProperties/service.cpp	(revision 30681)
@@ -147,5 +147,5 @@
  * Class containing the shared information service functionality.
  */
-class Service : public stdx::non_copyable
+class Service : public iprt::non_copyable
 {
 private:
Index: /trunk/src/VBox/Main/ApplianceImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ApplianceImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/ApplianceImpl.cpp	(revision 30681)
@@ -18,4 +18,5 @@
 
 #include <iprt/path.h>
+#include <iprt/cpp/utils.h>
 
 #include <VBox/com/array.h>
Index: /trunk/src/VBox/Main/ConsoleVRDPServer.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleVRDPServer.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/ConsoleVRDPServer.cpp	(revision 30681)
@@ -30,4 +30,5 @@
 #include <iprt/path.h>
 #include <iprt/alloca.h>
+#include <iprt/cpp/utils.h>
 
 #include <VBox/err.h>
Index: /trunk/src/VBox/Main/DHCPServerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/DHCPServerImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/DHCPServerImpl.cpp	(revision 30681)
@@ -22,4 +22,6 @@
 #include "AutoCaller.h"
 #include "Logging.h"
+
+#include <iprt/cpp/utils.h>
 
 #include <VBox/settings.h>
Index: /trunk/src/VBox/Main/DisplayImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/DisplayImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/DisplayImpl.cpp	(revision 30681)
@@ -27,4 +27,5 @@
 #include <iprt/thread.h>
 #include <iprt/asm.h>
+#include <iprt/cpp/utils.h>
 
 #include <VBox/pdmdrv.h>
Index: /trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp	(revision 30681)
@@ -22,4 +22,6 @@
 #include "Logging.h"
 #include "netif.h"
+
+#include <iprt/cpp/utils.h>
 
 #ifdef RT_OS_FREEBSD
Index: /trunk/src/VBox/Main/KeyboardImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/KeyboardImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/KeyboardImpl.cpp	(revision 30681)
@@ -24,5 +24,7 @@
 #include <VBox/com/array.h>
 #include <VBox/pdmdrv.h>
+
 #include <iprt/asm.h>
+#include <iprt/cpp/utils.h>
 
 // defines
Index: /trunk/src/VBox/Main/MachineDebuggerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineDebuggerImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/MachineDebuggerImpl.cpp	(revision 30681)
@@ -33,4 +33,5 @@
 #include <VBox/err.h>
 #include <VBox/hwaccm.h>
+#include <iprt/cpp/utils.h>
 
 // defines
Index: /trunk/src/VBox/Main/MediumAttachmentImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MediumAttachmentImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/MediumAttachmentImpl.cpp	(revision 30681)
@@ -23,4 +23,6 @@
 #include "AutoCaller.h"
 #include "Logging.h"
+
+#include <iprt/cpp/utils.h>
 
 ////////////////////////////////////////////////////////////////////////////////
Index: /trunk/src/VBox/Main/MediumFormatImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MediumFormatImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/MediumFormatImpl.cpp	(revision 30681)
@@ -24,4 +24,6 @@
 #include <VBox/VBoxHDD.h>
 
+#include <iprt/cpp/utils.h>
+
 // constructor / destructor
 /////////////////////////////////////////////////////////////////////////////
@@ -58,11 +60,11 @@
 
     /* The ID of the backend */
-    unconst (m.id) = aVDInfo->pszBackend;
+    unconst(m.id) = aVDInfo->pszBackend;
     /* The Name of the backend */
     /* Use id for now as long as VDBACKENDINFO hasn't any extra
      * name/description field. */
-    unconst (m.name) = aVDInfo->pszBackend;
+    unconst(m.name) = aVDInfo->pszBackend;
     /* The capabilities of the backend */
-    unconst (m.capabilities) = aVDInfo->uBackendCaps;
+    unconst(m.capabilities) = aVDInfo->uBackendCaps;
     /* Save the supported file extensions in a list */
     if (aVDInfo->papszFileExtensions)
Index: /trunk/src/VBox/Main/MediumImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MediumImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/MediumImpl.cpp	(revision 30681)
@@ -34,4 +34,5 @@
 #include <iprt/file.h>
 #include <iprt/tcp.h>
+#include <iprt/cpp/utils.h>
 
 #include <VBox/VBoxHDD.h>
Index: /trunk/src/VBox/Main/MouseImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MouseImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/MouseImpl.cpp	(revision 30681)
@@ -16,4 +16,6 @@
  */
 
+#include <iprt/cpp/utils.h>
+
 #include "MouseImpl.h"
 #include "DisplayImpl.h"
@@ -24,5 +26,7 @@
 
 #include <VBox/pdmdrv.h>
+
 #include <iprt/asm.h>
+
 #include <VBox/VMMDev.h>
 
Index: /trunk/src/VBox/Main/ProgressImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ProgressImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/ProgressImpl.cpp	(revision 30681)
@@ -34,4 +34,5 @@
 #include <iprt/time.h>
 #include <iprt/semaphore.h>
+#include <iprt/cpp/utils.h>
 
 #include <VBox/err.h>
Index: /trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp	(revision 30681)
@@ -24,4 +24,6 @@
 #include "Logging.h"
 
+#include <iprt/cpp/utils.h>
+
 #include <VBox/err.h>
 
Index: /trunk/src/VBox/Main/SnapshotImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/SnapshotImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/SnapshotImpl.cpp	(revision 30681)
@@ -36,4 +36,6 @@
 
 #include <iprt/path.h>
+#include <iprt/cpp/utils.h>
+
 #include <VBox/param.h>
 #include <VBox/err.h>
Index: /trunk/src/VBox/Main/SystemPropertiesImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/SystemPropertiesImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/SystemPropertiesImpl.cpp	(revision 30681)
@@ -31,4 +31,5 @@
 #include <iprt/process.h>
 #include <iprt/ldr.h>
+#include <iprt/cpp/utils.h>
 
 #include <VBox/err.h>
Index: /trunk/src/VBox/Main/USBDeviceImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/USBDeviceImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/USBDeviceImpl.cpp	(revision 30681)
@@ -21,4 +21,6 @@
 #include "Logging.h"
 
+#include <iprt/cpp/utils.h>
+
 // constructor / destructor
 /////////////////////////////////////////////////////////////////////////////
Index: /trunk/src/VBox/Main/VFSExplorerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/VFSExplorerImpl.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/VFSExplorerImpl.cpp	(revision 30681)
@@ -21,4 +21,5 @@
 #include <iprt/file.h>
 #include <iprt/s3.h>
+#include <iprt/cpp/utils.h>
 
 #include <VBox/com/array.h>
@@ -33,4 +34,6 @@
 #include "AutoCaller.h"
 #include "Logging.h"
+
+#include <memory>
 
 ////////////////////////////////////////////////////////////////////////////////
Index: /trunk/src/VBox/Main/glue/ErrorInfo.cpp
===================================================================
--- /trunk/src/VBox/Main/glue/ErrorInfo.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/glue/ErrorInfo.cpp	(revision 30681)
@@ -44,5 +44,5 @@
 ////////////////////////////////////////////////////////////////////////////////
 
-void ErrorInfo::init (bool aKeepObj /* = false */)
+void ErrorInfo::init(bool aKeepObj /* = false */)
 {
     HRESULT rc = E_FAIL;
@@ -144,5 +144,7 @@
 }
 
-void ErrorInfo::init (IUnknown *aI, const GUID &aIID, bool aKeepObj /* = false */)
+void ErrorInfo::init(IUnknown *aI,
+                     const GUID &aIID,
+                     bool aKeepObj /* = false */)
 {
     Assert(aI);
@@ -175,5 +177,5 @@
 }
 
-void ErrorInfo::init (IVirtualBoxErrorInfo *info)
+void ErrorInfo::init(IVirtualBoxErrorInfo *info)
 {
     AssertReturnVoid (info);
@@ -206,15 +208,16 @@
     gotAll &= SUCCEEDED(rc);
 
+    m_pNext = NULL;
+
     ComPtr<IVirtualBoxErrorInfo> next;
     rc = info->COMGETTER(Next) (next.asOutParam());
     if (SUCCEEDED(rc) && !next.isNull())
     {
-        mNext.reset (new ErrorInfo (next));
-        Assert(mNext.get());
-        if (!mNext.get())
+        m_pNext = new ErrorInfo(next);
+        Assert(m_pNext);
+        if (!m_pNext)
             rc = E_OUTOFMEMORY;
     }
-    else
-        mNext.reset();
+
     gotSomething |= SUCCEEDED(rc);
     gotAll &= SUCCEEDED(rc);
@@ -228,4 +231,9 @@
 ErrorInfo::~ErrorInfo()
 {
+    if (m_pNext)
+    {
+        delete m_pNext;
+        m_pNext = NULL;
+    }
 }
 
Index: /trunk/src/VBox/Main/glue/errorprint.cpp
===================================================================
--- /trunk/src/VBox/Main/glue/errorprint.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/glue/errorprint.cpp	(revision 30681)
@@ -28,5 +28,4 @@
 namespace com
 {
-
 
 void GluePrintErrorInfo(com::ErrorInfo &info)
@@ -75,5 +74,5 @@
 {
     // if we have full error info, print something nice, and start with the actual error message
-    com::ErrorInfo info(iface);
+    com::ErrorInfo info(iface, COM_IIDOF(IUnknown));
     if (info.isFullAvailable() || info.isBasicAvailable())
         GluePrintErrorInfo(info);
Index: /trunk/src/VBox/Main/webservice/vboxweb.cpp
===================================================================
--- /trunk/src/VBox/Main/webservice/vboxweb.cpp	(revision 30680)
+++ /trunk/src/VBox/Main/webservice/vboxweb.cpp	(revision 30681)
@@ -913,13 +913,15 @@
 
 /**
- * Raises a SOAP runtime fault.
+ * Raises a SOAP runtime fault. Implementation for the RaiseSoapRuntimeFault template
+ * function in vboxweb.h.
  *
  * @param pObj
  */
-void RaiseSoapRuntimeFault(struct soap *soap,
-                           HRESULT apirc,
-                           IUnknown *pObj)
-{
-    com::ErrorInfo info(pObj);
+void RaiseSoapRuntimeFault2(struct soap *soap,
+                            HRESULT apirc,
+                            IUnknown *pObj,
+                            const com::Guid &iid)
+{
+    com::ErrorInfo info(pObj, iid);
 
     WEBDEBUG(("   error, raising SOAP exception\n"));
Index: /trunk/src/VBox/Main/webservice/vboxweb.h
===================================================================
--- /trunk/src/VBox/Main/webservice/vboxweb.h	(revision 30680)
+++ /trunk/src/VBox/Main/webservice/vboxweb.h	(revision 30681)
@@ -73,5 +73,18 @@
 void RaiseSoapInvalidObjectFault(struct soap *soap, WSDLT_ID obj);
 
-void RaiseSoapRuntimeFault(struct soap *soap, HRESULT apirc, IUnknown *pObj);
+void RaiseSoapRuntimeFault2(struct soap *soap, HRESULT apirc, IUnknown *pObj, const com::Guid &iid);
+
+/**
+ * Template function called everywhere from methodmaps.cpp which calls
+ * RaiseSoapRuntimeFault2() with the correct COM interface ID.
+ * @param soap
+ * @param apirc
+ * @param pObj
+ */
+template <class T>
+void RaiseSoapRuntimeFault(struct soap *soap, HRESULT apirc, const ComPtr<T> &pObj)
+{
+    RaiseSoapRuntimeFault2(soap, apirc, pObj, COM_IIDOF(T));
+}
 
 /****************************************************************************
