Advertisement

03.20.2006 at 08:16AM PST, ID: 21780889
[x]
Attachment Details

warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)

Asked by racineconde in Microsoft Visual C++.Net

Tags: , , , ,

Hi,
Here's the other warning I receive when I compile the source code.
//------------------------
warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
//------------------------

The line incriminated is between two lines like this: //-------------------------------------------------------------------------

Here's all the code
//*************************** BEGINNING OF THE CODE
#ifndef cUnknownPtr_DEFINED
#define cUnknownPtr_DEFINED

template <typename T>
class cUnknownPtr
{
  T* ptr;
public:
  cUnknownPtr() : ptr(0)
  {
  }

  cUnknownPtr(T* p) : ptr(p)
  {
  }

  cUnknownPtr(const cUnknownPtr<T>& other) : ptr(other.ptr)
  {
    if(ptr)
    {
      ptr->AddRef();
    }
  }

  ~cUnknownPtr()
  {
    setNull();
  }

  cUnknownPtr<T>& operator = (const cUnknownPtr<T>& other) //treat as pointer
  {
    if(other.ptr != ptr)
    {
      if(ptr)ptr->Release();
      ptr = other.ptr;
      if(ptr)ptr->AddRef();
    }
    return *this;
  }

  T* operator -> () //treat as pointer
  {
    return ptr;
  }

  operator T* () //silent cast operator
  {
    return ptr;
  }

  T** operator & () //address of operator
  {
    return &ptr;
  }

  bool isValid()
  {
    return ptr != 0;
  }

  bool isNull()
  {
    return ptr == 0;
  }

  void setNull()
  {
    if(ptr)
    {
      ptr->Release();
      ptr = 0;
    }
  }

  bool QI(REFIID riid,void** ppObj)
  {
    if(isNull())return false;
    return SUCCEEDED(ptr->QueryInterface(riid,ppObj));
  }

//----------------------------------------------------------------------
void demandQI(REFIID riid,void** ppObj) throw(HRESULT)
//----------------------------------------------------------------------
  {
    if(isNull())throw E_FAIL;
    HRESULT hr = ptr->QueryInterface(riid,ppObj);
    if(FAILED(hr))
    {
      throw hr;
    }
  }
};

inline void checkResult(HRESULT r)
{
  if (FAILED(r))
    throw r;
}

#endif//cUnknownPtr_DEFINED
//*************************** END OF THE CODE

THANKS YOU FOR ANY ADVICE...
Start Free Trial
 
Loading Advertisement...
 
[+][-]03.20.2006 at 08:22AM PST, ID: 16236873

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual C++.Net
Tags: c4290, warning, exception, specification, ignored
Sign Up Now!
Solution Provided By: AlexFM
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.20.2006 at 08:45AM PST, ID: 16237123

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32