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++概念的新版本?
感謝
有一個偉大的日子
你最後的代碼是我正在搜索的東西,非常感謝:) –