-
Provide a swap member function when std::swap would be inefficient for your type. Make sure your swap doesn't throw exceptions.
-
If you offer a member swap, also offer a non-member swap that calls the member. For classes (not templates), specialize std::swap, too.
-
When calling swap, employ a using declaration for std::swap, then call swap without namespace qualification.
-
It's fine to totally specialize std templates for user-defined types, but never try to add something completely new to std.
Item 25: Consider support for a non-throwing swap(Effective C++)
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
51c大模型~合集25大模型