Reputation: 3356
For example,
template<class T,size_t N>
void swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a,*b)));
Under what condition will the function can, or cannot, throw an exception?
Upvotes: 1
Views: 74
Reputation: 96258
noexcept(noexcept(swap(*a,*b)))
The outer one is the noexcept specifier, the inner one is the noexcept operator.
It's noexcept
, if swap
for T
s is noexcept
.
That it's, it can only throw if that swap can throw.
Upvotes: 2
Reputation: 69854
quick explanation:
the inner noexcept
returns true
if the function swap(T&, T&)
is marked noexcept
.
the outer noexcept
marks this function as noexcept
if the inner noexcept
returns true.
Therefore, this function copies the noexcept
semantics of swap(T&, T&)
.
Upvotes: 2