【发布时间】:2019-02-08 13:18:18
【问题描述】:
我有一个包含多个模板参数的概念
template<typename T, typename U> EqualityComparable
我可以用这个吗
template< EqualityComparable T /* and U */ > void foo() {}
不知何故?
作为一个例子,考虑这个 sn-p
template <typename T, typename U>
concept EqualityComparable = requires(T a, U b) {
{a == b} -> bool;
{a != b} -> bool;
};
template<EqualityComparable T /* and U */>
void foo (T,U) {} //can i make this work?
int main () {
foo(1.0f,1);
}
godbolt 上的 clang 实验概念编译器告诉我
template<EqualityComparable T /* and U */> void foo(T,U) {}
--> error: concept 'EqualityComparable' requires more than 1 template argument; provide the remaining arguments explicitly to use it here
所以这似乎表明这是可能的?
【问题讨论】:
标签: c++ c++-concepts