c++ - 为什么 `std::remove_cv<_Iter>::type` 不是类型?
问题描述
我有两个版本的我希望是相同的功能,但 gcc 说版本 1 是有效的,而版本 2 给出了一个
expected a type, got 'std::remove_cv<_Iter>::type'
我不太明白这个错误,因为我希望该using
语句需要一个类型,并且不会自动将 a 提升'std::remove_cv<_Iter>::type'
为其他东西?
有人可以解释这里发生了什么吗?
template<typename U,typename V> constexpr inline auto is_same_rcv() noexcept
{
//version 1 works
using u_underlying = std::remove_cv<U>::type;
using v_underlying = std::remove_cv<V>::type;
return std::is_same<u_underlying,v_underlying>::value;
}
和
template<typename U,typename V> constexpr inline auto is_same_rcv() noexcept
{
//version 2 doesn't work
using u_underlying = std::remove_cv<U>::type;
return std::is_same<u_underlying,std::remove_cv<V>::type>::value;
}
相关的神螺栓
编辑好玩,看起来clang和gcc对using关键字的解释不同(见https://godbolt.org/z/P9Pcn6)
解决方案
推荐阅读
- javascript - React 使用表中的数据,从输入字段中获取数据并在单击按钮后使用数据向数据库发送请求
- c++ - 如何配置 pg_config/pgxs/make 来获取 Makefile 中的 CPPFLAGS 和 CFLAGS 来构建 Postgres C/C++ 扩展?
- python - 如何在python中绘制“多线”折线图
- java - 如何按范围spring boot jpa过滤对象?
- pyarrow - 如何精确控制 RecordBatch 的大小?
- c++ - C++ 从文件中读取 - 文件的第一行被跳过,最后一行被重复两次
- laravel - 无法在laravel中显示存储中的图像
- javascript - 如何在 DOM 中显示它
- python - 根据距离按顺序查找元素对
- java - java - 如何使用Java中的OAUTH签名http post请求并使用JSON对象作为正文传递?