Re: Handling utf8 data from SQLite
- From: Chris Vine <chris cvine freeserve co uk>
- To: "Gavin Lambert" <gavinl compacsort com>
- Cc: gtkmm-list gnome org
- Subject: Re: Handling utf8 data from SQLite
- Date: Mon, 12 Sep 2011 00:34:11 +0100
On Mon, 12 Sep 2011 10:42:46 +1200
"Gavin Lambert" <gavinl compacsort com> wrote:
> Quoth Chris Vine:
> > try {
> > std::cout << "DB - Password: " << password << std::endl;
> > }
> > catch (Glib::Exception& e) {
> > std::cerr << e.what().raw() << std::endl;
> > }
> > catch (std::exception& e) {
> > std::cerr << e.what() << std::endl;
> > }
>
> If you're going to catch exceptions as references (which you should),
> make sure you catch them as const references. Otherwise they may not
> catch all throw cases.
The exception throwing mechanism always copies the thrown exception
object as a non-const object, in C++98/03 at least, so it shouldn't make
any difference to the things caught; and to specify 'const' means that
only const methods of the exception object can be called in the catch
block (I realise that what() is a const method).
Section 4.3 of TC++PL (3rd Edition) says: "In addition, we can add
const to the type used to catch an exception in the same way that we can
add it to a function parameter. This doesn't change the set of
exceptions we can catch; it only restricts us from modifying the
exception caught."
Has this changed in C++11? If so, what additional excptions will a
const type in the catch statement cover which a non-const type will
not, under the new standard? (I have a copy of the draft standard so if
you can point me to the paragraph concerned that would be very helpful
- it is always nice to learn new things.)
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]