Skip to content

Commit b564b16

Browse files
ClaytonKnittelmergify[bot]
authored andcommitted
Cleanup: use proto DynamicCastMessage if available (#596)
Signed-off-by: Clayton Knittel <cknit1999@gmail.com> (cherry picked from commit c47393f)
1 parent aac2461 commit b564b16

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

core/include/gz/msgs/detail/dynamic_message_cast.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ template<typename MsgT>
3030
std::unique_ptr<MsgT>
3131
dynamic_message_cast(std::unique_ptr<google::protobuf::Message> &&_baseMsg)
3232
{
33+
#if GOOGLE_PROTOBUF_VERSION >= 5028000
34+
auto converted = std::unique_ptr<MsgT>{
35+
google::protobuf::DynamicCastMessage<MsgT>(_baseMsg.get())};
36+
#else
3337
auto converted = std::unique_ptr<MsgT>{dynamic_cast<MsgT*>(_baseMsg.get())};
38+
#endif
3439
if (converted) {
3540
// transfer ownership to a new unique_ptr object by releasing from old one
3641
(void) _baseMsg.release();

0 commit comments

Comments
 (0)