【发布时间】:2012-11-01 04:49:57
【问题描述】:
我最近开始使用std::reference_wrapper 类。在替换原始引用的某些用途时,我注意到我不必使用get() 函数将reference_wrappers 作为参数传递给采用普通引用的函数。
void foo(const T& a);
//...
T obj;
std::reference_wrapper<const T> ref(obj);
foo(ref); //works!
//foo(ref.get()); also works, but I expected that it would be required
std::reference_wrapper 在传递给函数时如何隐式转换为原始引用?
【问题讨论】:
标签: c++ reference c++11 implicit-conversion reference-wrapper