P
Pierre Rouleau
The std::exception class defined in the Standard C++ <exception> header
specifies that the constructors could throw any exception becuase they
do not have a throw() specification.
Why is that? Is this because there could be an exception thrown when
the code creates a std::exception? I would assume that is not the case.
However, if I want to create a new exception class, derived from
std::exception (say MyException) then how can I guarantee that creating
an instance of MyException will not generate any exception?
class MyException : public std::exception
{
public:
explicit MyException(int someinfo) throw();
// violates specs of std::exception
.....
};
Thanks for any information on this topic.
Pierre R.
specifies that the constructors could throw any exception becuase they
do not have a throw() specification.
Why is that? Is this because there could be an exception thrown when
the code creates a std::exception? I would assume that is not the case.
However, if I want to create a new exception class, derived from
std::exception (say MyException) then how can I guarantee that creating
an instance of MyException will not generate any exception?
class MyException : public std::exception
{
public:
explicit MyException(int someinfo) throw();
// violates specs of std::exception
.....
};
Thanks for any information on this topic.
Pierre R.