Why was std::swap moved to ?

后端 未结 1 1709
野趣味
野趣味 2021-02-12 10:44

Why has std::swap been moved to the header for C++11?

N3290 C.2.7 says:

17.6.3.2

Effect on

相关标签:
1条回答
  • 2021-02-12 10:55

    The committee wanted to allow you to use swap() without introducing a compile-time dependency on the large and more complex <algorithm> header file. Because swap() is so widely used, it makes sense to let you pull in its definition with as little additional baggage as possible; this will generally lead to faster compile times for files that don't otherwise need <algorithm>. Its new home allows it to be used without introducing unneeded overhead.

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