diff --git a/include/cppkafka/event.h b/include/cppkafka/event.h index 235d70e..a48175c 100644 --- a/include/cppkafka/event.h +++ b/include/cppkafka/event.h @@ -143,6 +143,13 @@ public: * * RD_KAFKA_EVENT_OFFSET_COMMIT */ TopicPartitionList get_topic_partition_list() const; + + /** + * Check whether this event is valid + * + * /return true iff this event has a valid (non-null) handle inside + */ + operator bool() const; private: using HandlePtr = std::unique_ptr; diff --git a/src/event.cpp b/src/event.cpp index 4f2fc5d..1c82d3d 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -90,4 +90,8 @@ TopicPartitionList Event::get_topic_partition_list() const { return convert(toppars_handle); } +Event::operator bool() const { + return !!handle_; +} + } // cppkafka