Код: Выделить всё
namespace Test
{
namespace concepts {
template
concept SupportsFn = requires(T t, int k) {
{
t.fn(k)
};
};
}
template
class CD {
static_assert(concepts::SupportsFn);
public:
void call(int k) {
this->fn(k);
}
};
template
class BD : public CD {
static_assert(concepts::SupportsFn);
public:
void call2(int k) {
this->fn(k + 2);
}
};
}
class ED : public Test::BD {
public:
void fn(int k) {
std::cout C:\temp\memfnexpt\memfnexpt\memfnexpt.cpp(368,2):
1> see declaration of 'Test::BD'
1> C:\temp\memfnexpt\memfnexpt\memfnexpt.cpp(367,11):
1> the concept 'Test::concepts::SupportsFn' evaluated to false
1> C:\temp\memfnexpt\memfnexpt\memfnexpt.cpp(353,5):
1> use of undefined type 'ED'
1> C:\temp\memfnexpt\memfnexpt\memfnexpt.cpp(377,7):
1> see declaration of 'ED'
1> C:\temp\memfnexpt\memfnexpt\memfnexpt.cpp(353,7):
Подробнее здесь: https://stackoverflow.com/questions/791 ... s-and-crtp