Re: STL and "function try blocks"

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Carl Daniel [VC++ MVP] wrote:
Function try
blocks have no value except for in constructors, as the contents of
the constructor-initializer-list is inside the function try block,
but outside the function body.

I'm not sure, but I expect thay have sence in destructors too. Thay should
catch exceptions in objects with automaticly called destructors(I know,
exceptions in destructors are evil!).

e.g.:
#include <iostream>

class Y{
public:
~Y(){
throw 0;
}
};

class X{
Y y;
public:
~X()try{
}
catch (int &) {
std::cout << "exception catched\n";
}
};







.



Relevant Pages

  • Re: advantages of C
    ... And constructors and destructors and templates and exceptions and ...
    (comp.programming)
  • Re: Allocators and exceptions
    ... actually wrong vis-a-vis the language definition. ... Because there is no constructors. ... As for your concern about efficiency of construction with exceptions. ... contract and so the compiler would say - aha, this is what you want, then I ...
    (comp.lang.ada)
  • Re: On assembly and portability (between Linux and Windows)
    ... >>any requirement to automatically call constructors and destructors. ... In order to be considered truely object oriented, a programming language ... and structure in an object-oriented computer program. ... I see no reason to require Constructors or Destructors. ...
    (alt.lang.asm)
  • Re: C++ Runtime Binding
    ... I believe you are under the misconception that constructors and ... destructors only, since these are the only ones affected in ATL3. ... > "Igor Tandetnik" wrote in message ... >>> called without the CRT? ...
    (microsoft.public.vc.atl)
  • Re: Operator overloading in C
    ... This means that the need of constructors or destructors ... gamut of applications is very effective in a cost/usge relationship. ...
    (comp.std.c)