Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++, "canceling a construction"

Name: Anonymous 2009-11-04 15:25

Hi /prog/

My is simple, but perhaps not so frequent.

How should I stop a construction of an object (c++)?

Basically I have a class with some data members which must fulfill some requirements. Say we initialize these data members upon construction, if the supplied values were erroneous then I guess I want to stop construction and throw an error. Is this the right idea? How do I "cancel the construction"?

Help much appreciated :)

Name: Anonymous 2009-11-09 17:57

>>52
You can do that with exceptions too with an equal amount of work. It also means you'll be using a C++ facility instead of a C workaround in C++!
Holy shit dude. You tell me sepples' exception support is better by pointing me to a processor-and-compiler-and-kernel-specific hack to get stack traces. The article has 'tricks for Linux' in the title for crying out loud. And that's not a workaround...

Yes, it's the same thing I was talking about with abort(). At least I admit that it's a hack! None of this exception support you rave about is even widely supported, let alone standardized. We don't all program for x86. We don't all program for Linux. We don't all compile with GCC or Intel. Keep drinking that kool-aid buddy.

That's why exceptions exist in the first place: to replace assert() and abort() with an alternative which can provide more information.
You haven't given more information at all! All you've proven is that the same hacks I've been using to get stack traces with abort() are available with exceptions (in an even more convoluted way, in the constructor to all your user-defined exceptions; good luck doing that with std::logic_error, std::range_error, etc.)

c) No tools
Why the fuck should you need tools to interpret something that is supposed to be a standard feature of the language? What possible tools could these be? I need a p-and-c-and-k-specific library for stack traces? I need the app to actually be hooked up to the debugger? What the fuck?

This is why people don't use sepples exceptions. They are just plain incomplete.

Also, you keep saying assert() is a workaround. What a joke.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List