什么是`使用std :: swap`里面的类方法实现的意思? [英] what does `using std::swap` inside the body of a class method implementation mean?
本文介绍了什么是`使用std :: swap`里面的类方法实现的意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我今天下午在做一些c ++练习,并试图学习并采用copy-swap惯用法对这个问题进行彻底的解释:复制交换习语。
I was doing some c++ practicing this afternoon, and was trying to learn and adopt the copy-swap idiom following this thoroughfully explanation on this question: the Copy-Swap Idiom.
但我发现了一些从未见过的代码: using std :: swap; // allow ADL
在这个例子中
But I found some code I had never seen: using std::swap; // allow ADL
in this example
class dumb_array
{
public:
// ...
void swap(dumb_array& pOther) // nothrow
{
using std::swap; // allow ADL /* <===== THE LINE I DONT UNDERSTAND */
swap(mSize, pOther.mSize); // with the internal members swapped,
swap(mArray, pOther.mArray); // *this and pOther are effectively swapped
}
};
-
在函数体内的
实现? - ADL是什么意思?
- what does
using std::swap;
mean inside the body of a function implementation ? - what does ADL mean ?
推荐答案
使用
关键字具有作用域效果。
The using
keyword has scoped effect.
这意味着 std :: swap $在
使用
关键字的范围内,可以将 swap
。
这篇关于什么是`使用std :: swap`里面的类方法实现的意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文