Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On noexcept arguments

Tags:

c++

c++11

c++14

The use of noexcept was pretty clear to me, as the modern optimized way of marking functions with the no throw exception guarantee

struct A {
    A() noexcept; 
}; 

In item 14 of effective modern c++ I ecountered the following syntax, referred to as conditionally noexcept

template<class T, size_t N>
void swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b))); 

The way I get it, is that noexcept can introduce a truth value context, but then again how can another noexcept be an argument ?

Could someone elaborate on the syntax and semantics of this use of noexcept ?

like image 276
Lorah Attkins Avatar asked Dec 08 '22 05:12

Lorah Attkins


1 Answers

With:

template<class T, size_t N>
void swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
                                  (1)      (2)
  • (1) is a noexcept specifier
  • (2) is a noexcept operator
like image 112
Jarod42 Avatar answered Dec 17 '22 16:12

Jarod42