Код: Выделить всё
// One of several that will follow this pattern.
class Timer8 {
public:
//...
using overflow_context = OverflowIrqCtx; // a struct.
using overflow_handler = void(*)(overflow_context* ovf_ctx, void* usr_ctx);
void SetOverflowIrqEnabled(bool enabled);
void SetOverflowIrqHandler(void* usr_ctx, overflow_handler handler);
//...
};
Код: Выделить всё
template
concept Timer = requires(T a) {
{ a.SetOverflowIrqEnabled(std::declval()) };
{ a.SetOverflowIrqHandler(std::declval(), std::declval()) };
};
Код: Выделить всё
scheduler.h: In substitution of 'template requires Timer class embedded::Scheduler [with T = embedded::time::Timer8]':
scheduler_test.cc:20:45: required from here
scheduler.h:16:9: required for the satisfaction of 'Timer' [with T = embedded::time::Timer8]
scheduler.h:16:17: in requirements with 'T a' [with T = embedded::time::Timer8]
scheduler.h:22:28: note: the required expression 'a.SetOverflowIrqHandler(std::declval(), declval())' is invalid, because
22 | { a.SetOverflowIrqHandler(std::declval(), std::declval()) };
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Подробнее здесь: https://stackoverflow.com/questions/793 ... -a-concept