Possible Duplicate:
Is there a generally accepted idiom for indicating C++ code can throw exceptions?
How do you indicate in your code when a C++ function is possible to throw something? I don't mean through documentation, but through syntax.
For example I tried placing a throw(std::exception)
at the end of the function declaration, but that gave me a warning saying that "C++ exception specification ignored except to indicate a function is not __declspec(nothrow)", which I guess means the compiler ignored the throw
and proceeded as if it were not there.
I also tried adding a throw()
(without anything in the parenthesis) at the end of the declaration, but — contrary to my expectations — that means the function is expected to never throw anything: "function assumed not to throw an exception but does".
Atm I'm using throw(...)
to syntactically indicate the function may throw as this doesn't give me any errors or warnings. Do you have any other suggestions as to how I might indicate this through syntax?