Topic: std::exception not wchar_t complient?


Author: "Jim Cobban" <thesnaguy@hotmail.com>
Date: Wed, 10 Jan 2001 23:54:16 GMT
Raw View
<peter_c_murray@my-deja.com> wrote in message
news:92u8gf$7ct$1@nnrp1.deja.com...
>
>
> The std library I'm using (VC6/Plauger) has the following member
> function in std::exception
>
>     virtual const char *what() const throw();
>
> Is it correct that there is no wchar_t version of this?  Or is there an
> equivalent wchar_t specialised std exception that I don't know about?

That is what the standard says (s. 18.6.1).  If there were a method
returning wchar_t it could not also be called what() as you cannot have two
methods which differ only in return type.  You also cannot overload what()
in a derived exception with a different returned value.  But you have an
implied point that this imposes the restriction that the textual description
of an exception cannot contain multilingual characters.

However that restriction only applies to the exceptions which have been
defined in the standard.  You can always define your own exception base
class, say WException which adds a virtual method virtual const wchar_t *
wwhat() const throw() and derive all of your exceptions from that class.
Then you can do catch(WException e) { std:wcerr << wwhat(); } for example.

---
[ 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: Ron Natalie <ron@spamcop.net>
Date: Wed, 3 Jan 2001 18:08:01 GMT
Raw View

peter_c_murray@my-deja.com wrote:
>
> The std library I'm using (VC6/Plauger) has the following member
> function in std::exception
>
>     virtual const char *what() const throw();
>
> Is it correct that there is no wchar_t version of this?  Or is there an
> equivalent wchar_t specialised std exception that I don't know about?
>

Nope.  C++ (and C for that matter) don't provide really provide
wide character support for interfaces other than the string handlers
and the contents of data streams.  You'll have to convert it
yourself if you need a wide version.

---
[ 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: peter_c_murray@my-deja.com
Date: Wed, 3 Jan 2001 17:35:15 GMT
Raw View

The std library I'm using (VC6/Plauger) has the following member
function in std::exception

    virtual const char *what() const throw();

Is it correct that there is no wchar_t version of this?  Or is there an
equivalent wchar_t specialised std exception that I don't know about?

Thanks.




Sent via Deja.com
http://www.deja.com/

---
[ 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.     ]