C++从通用引用中提取实际类型
C++ extract actual type from universal reference
如何提取通用引用的实际类型,如下所示:
template<class T>
void foo(T&& value) {
otherFunction<...>(value);
我想用实际的值类型替换...
,即既不T&
也不T&&
或const T&
,而只是T
.
另外,我真的需要std::forward
值吗?因为otherFunction
只接受实际值,所以无论如何它都会删除任何类型的引用。那么我不需要std::forward
是正确的吗?
使用std::remove_reference
.它会把int
、int&
和int&&
变成int
。
相关文章:
- C++从通用引用中提取实际类型
- Clang 工具,用于提取给定 lambda 类型的 lambda 主体
- 将不同类型的模板参数包提取到双精度向量中会产生警告
- 在C++如何从数组中提取成员并返回成员类型的数组?
- 从 Any 包中提取和匹配 protobuf 消息类型名的首选方法
- 从具有部分专用化的boost:hana::set中提取类型失败
- 如何提取模板参数中传递的类型
- 从 std::set 中提取仅移动类型
- 需要根据读取的数据类型将ifstream提取到单独的数组中
- 如何定义变体<x,y,z>提取模板参数的子类型
- 从传递给模板函数的内部类实例中提取外部类类型
- 防止为字符串流提取运算符不支持的类型实例化模板类 (>>)
- C++ HDF5 提取复合数据类型的一个成员
- 从参数包中提取成员类型
- 如何使用 boost::p ython 从 Python 类型中提取包装的C++类型
- 从字符串中提取不同的数据类型变量
- 您可以从模板参数函数签名中提取类型吗?
- c++:有没有办法从实例化的模板中提取类型?
- 从printf格式字符串中提取类型信息
- 是否可以自动从可区分的联合中提取类型