LINUX.ORG.RU

impicit noexcept

 


0

2

В стандарте сказано следующее:

An inheriting constructor (12.9) and an implicitly declared special member function (Clause 12) have an exception-specification. If f is an inheriting constructor or an implicitly declared default constructor, copy constructor, move constructor, destructor, copy assignment operator, or move assignment operator, its implicit exception-specification specifies the type-id T if and only if T is allowed by the exception-specification of a function directly invoked by f’s implicit definition; f allows all exceptions if any function it directly invokes allows all exceptions, and f has the exception-specification noexcept(true) if every function it directly invokes allows no exceptions. [ Note: It follows that f has the exception-specification noexcept(true) if it invokes no other functions. — end note ]

Меня сбивает дополнение после точки с запятой: «f allows all exceptions if any function it directly invokes allows all exceptions… noexcept(true) if every function it directly invokes allows no exceptions ». Не понимаю: имеется ввиду все тот же конкретный случай неявно заданных специальных функций-членов или это уже отдельный факт, который не зависит от того, явно или неявно объявлена f. Что скажете?


Ответ на: комментарий от utf8nowhere

Получается, стандарт не гарантирует, что конструктор будет noexcept в таком случае:

class A {
public:
    A() {}
};
? Это весьма странно кмк.

maked0n
() автор топика
Ответ на: комментарий от utf8nowhere

Ок, ответ понял. А есть предположения почему так? Кажется, что можно было бы гарантировать и ничего плохого от этого не было бы.

maked0n
() автор топика
Ответ на: комментарий от maked0n

noexcept нельзя объявить, а потом убрать - это поломает ABI. Поэтому и не объявляют noexcept неявно.

dzidzitop ★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.