On Thursday, 16 July 2015 07:03:33 UTC+3, fl wrote:
> Hi, C++ experts:
>
> From the following description,
> ...........
> The result is false if the expression contains at least one of the following potentially evaluated constructs:
> 1. call to any type of function that does not have non-throwing exception
> specification, unless it is a constant expression.
> 2. throw expression.
> 3. dynamic_cast expression when the target type is a reference type, and
> conversion needs a run time check
> 4. typeid expression when argument type is polymorphic class type
> .......
>
> I cannot understand why the copy ctor in class U has a noexcept(false) in
> the below example code.
>
> Could you tell me the reason?
Default copy constructor just does copy-construct all bases and
members. U's member v is vector whose copy constructor may throw.
Therefore U's default copy constructor may also throw what v's
constructor throws and so it can't be 'noexcept'.