【发布时间】:2020-10-16 11:31:38
【问题描述】:
我怎样才能像这样提取通用引用的实际类型:
template<class T>
void foo(T&& value) {
otherFunction<...>(value);
我想将... 替换为值的实际类型,即既不是T& 或T&& 也不是const T&,而只是T。
另外,我真的需要std::forward 值吗?因为otherFunction 只接受实际值,所以无论如何它都会丢弃任何类型的引用。那么我不需要std::forward 是否正确?
【问题讨论】:
标签: c++ reference c++17 forwarding-reference