Questions tagged «std-swap»

2
为什么C ++ 20之前std :: swap没有标记为constexpr?
在C ++ 20中,std::swap成为一个constexpr函数。 我知道标准库在标记事物方面确实落后于该语言constexpr,但是到了2017年,<algorithm>它和许多其他事物一样已经成为constexpr了。但是- std::swap不是。我隐约记得有一些奇怪的语言缺陷阻止了这种标记,但是我忘记了细节。 有人可以简洁明了地解释吗? 动机:需要理解为什么在C ++ 11 / C ++ 14代码中标记std::swap()类似函数的想法可能不是一个好主意constexpr。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.