为什么 C++20 不允许在 requires 表达式中使用类型别名?

问题描述

#include <type_traits>

struct MyType { void operator [](int) const {} };

template<typename T>
concept IsMyType1 = requires(T obj)
{
    { obj[0] };
    using U = std::remove_cvref_t<T>; // error
    requires std::is_same_v<U,MyType>;
};

template<typename T>
concept IsMyType2 = requires(T obj)
{
    { obj[0] };
    requires std::is_same_v<std::remove_cvref_t<T>,MyType>; // okay
};

int main() {}

为什么 C++20 不允许在 requires 表达式中使用类型别名?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...