crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )


  Ответ в Задачка N6
Введите ваше имя
Подтвердите код

Введите в поле код из 6 символов, отображенных в виде изображения. Если вы не можете прочитать код с изображения, нажмите на изображение для генерации нового кода.
 

Опции сообщения
 Включить смайлы?
Иконки сообщения
(Опционально)
                                
                                
  [ Без иконки ]
 


Последние 10 сообщений [ в обратном порядке ]
Tonal Дата 12.4.2008, 18:25
  Поэтому правило простое: ловить исключение по const& (кроме примитивных типов) чтобы не было сюрпризов.
А примитивные - лучше не бросать.
archimed7592 Дата 11.4.2008, 22:08
 
Цитата
А вот если в первом catch ловить по ссылке - будет таки 6.

Действительно :).
http://www.kuzbass.ru:8086/docs/isocpp/exc...ml#except.throw
Цитата
-3- A throw-expression initializes a temporary object, the type of which is determined by removing any top-level cv-qualifiers from the static type of the operand of throw and adjusting the type from ``array of T'' or ``function returning T'' to ``pointer to T'' or ``pointer to function returning T'', respectively. [Note: the temporary object created for a throw-expression that is a string literal is never of type char* or wchar_t*; that is, the special conversions for string literals from the types ``array of const char'' and ``array of const wchar_t'' to the types ``pointer to char'' and ``pointer to wchar_t'', respectively (conv.array), are never applied to a throw-expression. ] The temporary is used to initialize the variable named in the matching handler (except.handle). The type of the throw-expression shall not be an incomplete type, or a pointer or reference to an incomplete type, other than void*, const void*, volatile void*, or const volatile void*. Except for these restrictions and the restrictions on type matching mentioned in except.handle, the operand of throw is treated exactly as a function argument in a call (expr.call) or the operand of a return statement.

-4- The memory for the temporary copy of the exception being thrown is allocated in an unspecified way, except as noted in basic.stc.dynamic.allocation. The temporary persists as long as there is a handler being executed for that exception. In particular, if a handler exits by executing a throw; statement, that passes control to another handler for the same exception, so the temporary remains. When the last handler being executed for the exception exits by any means other than throw; the temporary object is destroyed and the implementation may deallocate the memory for the temporary object; any such deallocation is done in an unspecified way. The destruction occurs immediately after the destruction of the object declared in the exception-declaration in the handler.

http://www.kuzbass.ru:8086/docs/isocpp/exc...l#except.handle
Цитата
-19- When the handler declares a non-constant object, any changes to that object will not affect the temporary object that was initialized by execution of the throw-expression. When the handler declares a reference to a non-constant object, any changes to the referenced object are changes to the temporary object initialized when the throw-expression was executed and will have effect should that object be rethrown.
Tonal Дата 11.4.2008, 20:27
  А вот если в первом catch ловить по ссылке - будет таки 6. :)
Andrew Selivanov Дата 11.4.2008, 16:54
 
Цитата(archimed7592 @ 11.4.2008, 17:50) *
Andrew Selivanov, неа :).

блин, не посмотрел, что второй throw внутри try... пять будет, пять)
archimed7592 Дата 11.4.2008, 16:50
  Andrew Selivanov, неа :).
Andrew Selivanov Дата 11.4.2008, 16:45
  гарантированный abnormal termination?
трям) не угадал
ViGOur Дата 11.4.2008, 12:56
  Ну мало ли что там может вылезти еще, например 6, или еще куда прынгет... :)
archimed7592 Дата 11.4.2008, 12:48
  5 вылезет... А что ещё может вылезти? :)
ViGOur Дата 11.4.2008, 12:00
 
Цитата(LuckLess @ 11.4.2008, 12:57) *
блин.. как значек № рисовать...
В русской раскладке 3 c шифтом. :)
LuckLess Дата 11.4.2008, 11:57
  блин.. как значек № рисовать...
Просмотр темы полностью (откроется в новом окне)
RSS Текстовая версия Сейчас: 29.3.2024, 5:11