I'd like to apply __declspec(nothrow)
on some of my member functions that return object references. For example, I'd like to add it to this function (in MyClass.h):
CMyClass& operator= ( IN UInt32 nValue )
{
return ( SetValue ( nValue ) );
};
The VC++ documentation says that I need to add it after the return type of the function like so:
return-type __declspec(nothrow) [call-convention] function-name ([argument-list])
If I follow this, most of my functions work fine with __declspec(nothrow)
. However, when I do that for the above member function (or any others that return a CMyClass&
), I get compile errors:
error C2059: syntax error : '__declspec(nothrow)'
I can put it in front of the return type and it compiles then but the documentation also says that if a __declspec() is placed in the wrong place, the compiler may ignore it without warning or error.
What's the right way of using __declspec(nothrow)
?