|
Boost : |
From: Hendrik Schober (boost_at_[hidden])
Date: 2002-06-24 10:28:01
"Ted Byers" <r.ted.byers_at_[hidden]> wrote:
> > "Ted Byers" <r.ted.byers_at_[hidden]> wrote:
> > > [...]
> > > However, my base exception also allows for the user (the programmers'
> using
> > > code) to set a custom message for each place where an exception can be
> > > thrown. so you could have something like:
> > >
> > > void f(void) {
> > > ERROR_STACKTRACE_BEGIN
> > > static std::string msg;
> > > static const std::string msgA("Here");
> > > msg = msgA;
> > > bool rcA = Herefunction();
> > > ...
> > > static const std::string msgB("There");
> > > bool rcB = ThereFunction();
> > > ...
> > > ERROR_STACKTRACE_END
> > > };
>
> [...]
>
> Second, the strings I am using are static constant strings, except for the
> one used directly by my macros, so if I understand things correctly, they'll
> be already constructed in the data segment of the program once the program
> is running [...]
I doubt that many compilers will compile-time-initialize
UDTs.
> [...] If this is correct, to have this usage not throw, all I
> have to focus on the default and copy constructors, and assignment operator.
Why don't you simply avoid the copying?
static std::string* msg;
static const std::string msgA("Here");
msg = &msgA;
bool rcA = Herefunction();
...
static const std::string msgB("There");
msg = &msgB;
bool rcB = ThereFunction();
Once you do that, you might as well use 'char*' anyway.
I doubt any compiler would _not_ init that at compile
time. :)
> But using more try/catch blocks does not get rid of the string problem
> because most of the data members in my traceable exception classes are
> std::string. Thus, I have to alter my use of them, or replace them, so that
> default and copy construction, and assignment, do not throw anyway,
> regardless of whether I use multiple try/catch blocks or my message strings.
Maybe COW should do that.
> [...]
> > I don't know much about the details of SEH, but I think these
> > exceptions are synchronous. But I really don't knwo that.
> >
> I was wondering aloud here about "how did they do that?" Presumably the OS
> has to use a signal handler to get the hardware exceptions, in order to be
> able to throw a structured exception. But if you can't do much but set an
> atomic flag, how did they do it? And if they can do it, why can't we?
As I said, I don't know much about how they did that.
(But I don't see why they need an implementation based
on signals.)
> Cheers,
>
> Ted
Schobi
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk