Skip to content

Commit

Permalink
fix(autoware_auto_common): nullptr_t (#7212)
Browse files Browse the repository at this point in the history
Signed-off-by: Shumpei Wakabayashi <[email protected]>
  • Loading branch information
shmpwk authored Jun 2, 2024
1 parent 573d816 commit 8416d2c
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using TimeStamp = builtin_interfaces::msg::Time;

/// \brief Helper class to check existence of header file in compile time:
/// https://stackoverflow.com/a/16000226/2325407
template <typename T, typename = nullptr_t>
template <typename T, typename = std::nullptr_t>
struct HasHeader : std::false_type
{
};
Expand All @@ -48,60 +48,60 @@ struct HasHeader<T, decltype((void)T::header, nullptr)> : std::true_type

/////////// Template declarations

/// Get frame id from message. nullptr_t is used to prevent template ambiguity on
/// Get frame id from message. std::nullptr_t is used to prevent template ambiguity on
/// SFINAE specializations. Provide a default value on specializations for a friendly API.
/// \tparam T Message type.
/// \param msg Message.
/// \return Frame id of the message.
template <typename T, nullptr_t>
template <typename T, std::nullptr_t>
const std::string & get_frame_id(const T & msg) noexcept;

/// Get a reference to the frame id from message. nullptr_t is used to prevent
/// Get a reference to the frame id from message. std::nullptr_t is used to prevent
/// template ambiguity on SFINAE specializations. Provide a default value on
/// specializations for a friendly API.
/// \tparam T Message type.
/// \param msg Message.
/// \return Frame id of the message.
template <typename T, nullptr_t>
template <typename T, std::nullptr_t>
std::string & get_frame_id(T & msg) noexcept;

/// Get stamp from message. nullptr_t is used to prevent template ambiguity on
/// Get stamp from message. std::nullptr_t is used to prevent template ambiguity on
/// SFINAE specializations. Provide a default value on specializations for a friendly API.
/// \tparam T Message type.
/// \param msg Message.
/// \return Frame id of the message.
template <typename T, nullptr_t>
template <typename T, std::nullptr_t>
const TimeStamp & get_stamp(const T & msg) noexcept;

/// Get a reference to the stamp from message. nullptr_t is used to prevent
/// Get a reference to the stamp from message. std::nullptr_t is used to prevent
/// template ambiguity on SFINAE specializations. Provide a default value on
/// specializations for a friendly API.
/// \tparam T Message type.
/// \param msg Message.
/// \return Frame id of the message.
template <typename T, nullptr_t>
template <typename T, std::nullptr_t>
TimeStamp & get_stamp(T & msg) noexcept;

/////////////// Default specializations for message types that contain a header.
template <class T, typename std::enable_if<HasHeader<T>::value, nullptr_t>::type = nullptr>
template <class T, typename std::enable_if<HasHeader<T>::value, std::nullptr_t>::type = nullptr>
const std::string & get_frame_id(const T & msg) noexcept
{
return msg.header.frame_id;
}

template <class T, typename std::enable_if<HasHeader<T>::value, nullptr_t>::type = nullptr>
template <class T, typename std::enable_if<HasHeader<T>::value, std::nullptr_t>::type = nullptr>
std::string & get_frame_id(T & msg) noexcept
{
return msg.header.frame_id;
}

template <class T, typename std::enable_if<HasHeader<T>::value, nullptr_t>::type = nullptr>
template <class T, typename std::enable_if<HasHeader<T>::value, std::nullptr_t>::type = nullptr>
TimeStamp & get_stamp(T & msg) noexcept
{
return msg.header.stamp;
}

template <class T, typename std::enable_if<HasHeader<T>::value, nullptr_t>::type = nullptr>
template <class T, typename std::enable_if<HasHeader<T>::value, std::nullptr_t>::type = nullptr>
TimeStamp get_stamp(const T & msg) noexcept
{
return msg.header.stamp;
Expand Down

0 comments on commit 8416d2c

Please sign in to comment.