相关疑难解决方法(0)

约束包含仅适用于概念吗?

考虑这个例子:

template <typename T> inline constexpr bool C1 = true;    
template <typename T> inline constexpr bool C2 = true;

template <typename T> requires C1<T> && C2<T> 
constexpr int foo() { return 0; }

template <typename T> requires C1<T> 
constexpr int foo() { return 1; }

constexpr int bar() {
    return foo<int>();
}
Run Code Online (Sandbox Code Playgroud)

调用是foo<int>()不明确的,还是约束C1<T> && C2<T>包含C1<T>

c++ c++-concepts c++20

17
推荐指数
1
解决办法
425
查看次数

标签 统计

c++ ×1

c++-concepts ×1

c++20 ×1