4
我尝试这个小片的代码,我从概念技术规范修改:C++概念:无效引用功能概念
template < typename T >
concept bool C_Object() {
return requires {
T();
};
}
template < typename Object >
requires C_Object<Object>
class Foo {
public:
Object test;
};
struct Component {
int data;
Component() : data(0) {}
};
int main() {
Foo<Component> test;
return 0;
}
但我得到这个错误:
test.cpp:10:12: error: invalid reference to function concept ‘template<class T> concept bool C_Object()’
requires C_Object<Object>
^~~~~~~~~~~~~~~~
test.cpp: In function ‘int main()’:
test.cpp:26:16: error: template constraint failure
Foo<Component> test;
^
test.cpp:26:16: note: constraints not satisfied
test.cpp:26:16: note: ill-formed constraint
第一次余尝试我缺少的C++概念的新版本?
感谢
有一个伟大的日子
你最后的代码是我正在搜索的东西,非常感谢:) –