Why is swapping multidimensional arrays not noexcept?

前端 未结 1 1717
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 01:59

I have the following snippet:

#include 
#include 

int main(int argc, char** argv) {
    int x[2][3];
    int y[2][3];

    usin         


        
相关标签:
1条回答
  • 2021-02-04 02:49

    This overload:

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

    is not in scope until ;, so swap(*a, *b) doesn't consider this overload. This is because of:

    3.3.2/1 The point of declaration for a name is immediately after its complete declarator (Clause 8) and before its initializer (if any) …

    and the exception specification is part of the declarator.

    0 讨论(0)
提交回复
热议问题