Skip to content

Commit

Permalink
Move always_false_v to detail namespace (ros2#2232)
Browse files Browse the repository at this point in the history
Since this is a common idiom, especially under this name, we should
define the `always_false_v` template within a namespace to avoid
conflict with other libraries and user code. This could either be
`rclcpp::detail` if it's intended only for internal use or just `rclcpp`
if it's intended as a public helper. In this PR, I've initially chosen
the former.

Signed-off-by: Nathan Wiebe Neufeldt <nwiebeneufeldt@clearpath.ai>
  • Loading branch information
nwn authored and Barry-Xu-2018 committed Jul 14, 2023
1 parent c9b9460 commit 062b20c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rclcpp/include/rclcpp/any_subscription_callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
#include "rclcpp/type_adapter.hpp"


template<class>
inline constexpr bool always_false_v = false;

namespace rclcpp
{

namespace detail
{

template<class>
inline constexpr bool always_false_v = false;

template<typename MessageT, typename AllocatorT>
struct MessageDeleterHelper
{
Expand Down Expand Up @@ -580,7 +580,7 @@ class AnySubscriptionCallback
}
// condition to catch unhandled callback types
else { // NOLINT[readability/braces]
static_assert(always_false_v<T>, "unhandled callback type");
static_assert(detail::always_false_v<T>, "unhandled callback type");
}
}, callback_variant_);
TRACETOOLS_TRACEPOINT(callback_end, static_cast<const void *>(this));
Expand Down Expand Up @@ -660,7 +660,7 @@ class AnySubscriptionCallback
}
// condition to catch unhandled callback types
else { // NOLINT[readability/braces]
static_assert(always_false_v<T>, "unhandled callback type");
static_assert(detail::always_false_v<T>, "unhandled callback type");
}
}, callback_variant_);
TRACETOOLS_TRACEPOINT(callback_end, static_cast<const void *>(this));
Expand Down Expand Up @@ -790,7 +790,7 @@ class AnySubscriptionCallback
}
// condition to catch unhandled callback types
else { // NOLINT[readability/braces]
static_assert(always_false_v<T>, "unhandled callback type");
static_assert(detail::always_false_v<T>, "unhandled callback type");
}
}, callback_variant_);
TRACETOOLS_TRACEPOINT(callback_end, static_cast<const void *>(this));
Expand Down Expand Up @@ -924,7 +924,7 @@ class AnySubscriptionCallback
}
// condition to catch unhandled callback types
else { // NOLINT[readability/braces]
static_assert(always_false_v<T>, "unhandled callback type");
static_assert(detail::always_false_v<T>, "unhandled callback type");
}
}, callback_variant_);
TRACETOOLS_TRACEPOINT(callback_end, static_cast<const void *>(this));
Expand Down

0 comments on commit 062b20c

Please sign in to comment.