Skip to content

Commit a430093

Browse files
authored
Cleanup: use proto DynamicCastMessage if available (#596) (#599)
(cherry picked from commit c47393f) Signed-off-by: Clayton Knittel <cknit1999@gmail.com>
1 parent 562d913 commit a430093

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
@@ -37,7 +37,12 @@ template<typename MsgT>
3737
std::unique_ptr<MsgT>
3838
dynamic_message_cast(std::unique_ptr<google::protobuf::Message> &&_baseMsg)
3939
{
40+
#if GOOGLE_PROTOBUF_VERSION >= 5028000
41+
auto converted = std::unique_ptr<MsgT>{
42+
google::protobuf::DynamicCastMessage<MsgT>(_baseMsg.get())};
43+
#else
4044
auto converted = std::unique_ptr<MsgT>{dynamic_cast<MsgT*>(_baseMsg.get())};
45+
#endif
4146
if (converted) {
4247
(void) _baseMsg.release();
4348
}

0 commit comments

Comments
 (0)