masaori335 commented on a change in pull request #6996:
URL: https://github.com/apache/trafficserver/pull/6996#discussion_r453377616
##########
File path: iocore/eventsystem/I_Continuation.h
##########
@@ -63,6 +63,26 @@ extern EThread *this_event_thread();
typedef int (Continuation::*ContinuationHandler)(int event, void *data);
+// Convert event handler pointer fp to type ContinuationHandler, but with a
compiler error if class C is not
+// derived from the class Continuation.
Review comment:
Can we check this at compile time & avoid casting twice like this?
```
template <class C, typename T>
constexpr ContinuationHandler
continuation_handler_void_ptr(int (C::*fp)(int, T *))
{
static_assert(std::is_base_of<Continuation, C> && std::is_convertible<C,
Continuation>);
return reinterpret_cast<fp>;
}
```
BTW, we can check this clearly with the c++20 concept
```
template <class C, typename T>
requires std::derived_from(C, Continuation)
constexpr ContinuationHandler
continuation_handler_void_ptr(int (C::*fp)(int, T *))
{
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]