Возможно, это просто плохо, но я не понимаю почему. И не нашел никакого примера с конструктором. Или, может быть, это не имеет ничего общего с конструктором ...C++ Concepts: CRTP
template < typename T >
concept bool C_Object() {
return requires {
T();
};
}
template < C_Object Object>
class DefaultManager {
// Content;
};
template < C_Object Derived >
class Component {
// Content
};
struct Test : public Component<Test> {
int data;
Test() = default;
};
int main() {
Test test;
return 0;
}
Дайте ошибку:
test2.cpp:21:36: error: template constraint failure
struct Test : public Component<Test> {
^
test2.cpp:21:36: note: constraints not satisfied
test2.cpp:2:14: note: within ‘template<class T> concept bool C_Object() [with T = Test]’
concept bool C_Object() {
^~~~~~~~
test2.cpp:2:14: note: the required expression ‘T()’ would be ill-formed
Это звучит как: «Эй, мой код не работает, пожалуйста, исправить это», извините.
В любом случае спасибо
великий день
Вы знаете, что концепции не дошли до стандарта? – SergeyA
@SergeyA да, возможно, C++ 20 –