Skip to content

Commit

Permalink
Move always_false_v to detail namespace (#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 Jul 5, 2023
1 parent 2e355e4 commit 588dba7
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 588dba7

Please sign in to comment.