Topic: Which is the std conforming exception spec?
Author: Jan van Mansum <jvm@ysabel.com>
Date: Fri, 15 Dec 2000 14:04:46 GMT Raw View
Hello group,
Given this header file:
// X.h
class X
{
class some_exception {};
void f() throw(some_exception)
// etc
};
Which definition is the correct exception specification (standard
conforming)?
// X.cpp
// ...
void X::f() throw(some_exception)
// etc.
or
// ...
void X::f() throw(X::some_exception)
// etc.
In my book they use the first, but it is not accepted by Borland 5.5.1
for
Win32.
Thanks in advance and regards,
Jan van Mansum.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: James Kuyper <kuyper@wizard.net>
Date: Fri, 15 Dec 2000 14:38:57 GMT Raw View
Jan van Mansum wrote:
>
> Hello group,
>
> Given this header file:
> // X.h
> class X
> {
> class some_exception {};
> void f() throw(some_exception)
>
> // etc
> };
>
> Which definition is the correct exception specification (standard
> conforming)?
> // X.cpp
> // ...
> void X::f() throw(some_exception)
> // etc.
>
> or
> // ...
> void X::f() throw(X::some_exception)
> // etc.
>
> In my book they use the first, but it is not accepted by Borland 5.5.1
> for
> Win32.
The some_exception identifier has class scope, which means that it's in
scope includes the default arguments and the function bodies and
ctor-initializers of all member functions of X. Unfortunately, the
exception specification is part of the declarator, not part of the
function body, and hence not in class scope. It doesn't matter that the
exception specification comes between the default arguments and the
initializers - class scope is turned off between them. Therefore, you
have to qualify some_exception with an X:: in order to use it.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]