Move function_traits templates to a separate namespace
This commit is contained in:
parent
e95d3f249d
commit
26d52d949e
5 changed files with 89 additions and 61 deletions
|
@ -57,7 +57,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
SharedPtrCallback
|
SharedPtrCallback
|
||||||
>::value
|
>::value
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
SharedPtrWithRequestHeaderCallback
|
SharedPtrWithRequestHeaderCallback
|
||||||
>::value
|
>::value
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
SharedPtrCallback
|
SharedPtrCallback
|
||||||
>::value
|
>::value
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
SharedPtrWithInfoCallback
|
SharedPtrWithInfoCallback
|
||||||
>::value
|
>::value
|
||||||
|
@ -100,7 +100,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
ConstSharedPtrCallback
|
ConstSharedPtrCallback
|
||||||
>::value
|
>::value
|
||||||
|
@ -114,7 +114,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
ConstSharedPtrWithInfoCallback
|
ConstSharedPtrWithInfoCallback
|
||||||
>::value
|
>::value
|
||||||
|
@ -128,7 +128,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
UniquePtrCallback
|
UniquePtrCallback
|
||||||
>::value
|
>::value
|
||||||
|
@ -142,7 +142,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
UniquePtrWithInfoCallback
|
UniquePtrWithInfoCallback
|
||||||
>::value
|
>::value
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
CallbackType
|
CallbackType
|
||||||
>::value
|
>::value
|
||||||
|
@ -161,7 +161,7 @@ public:
|
||||||
template<
|
template<
|
||||||
typename CallbackT,
|
typename CallbackT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::same_arguments<
|
rclcpp::function_traits::same_arguments<
|
||||||
CallbackT,
|
CallbackT,
|
||||||
CallbackWithRequestType
|
CallbackWithRequestType
|
||||||
>::value
|
>::value
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
namespace rclcpp
|
namespace rclcpp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace function_traits
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
/* NOTE(esteve):
|
/* NOTE(esteve):
|
||||||
* We support service callbacks that can optionally take the request id,
|
* We support service callbacks that can optionally take the request id,
|
||||||
* which should be possible with two overloaded create_service methods,
|
* which should be possible with two overloaded create_service methods,
|
||||||
|
@ -106,6 +110,8 @@ struct same_arguments : std::is_same<
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
} // namespace function_traits
|
||||||
|
|
||||||
} // namespace rclcpp
|
} // namespace rclcpp
|
||||||
|
|
||||||
#endif // RCLCPP__FUNCTION_TRAITS_HPP_
|
#endif // RCLCPP__FUNCTION_TRAITS_HPP_
|
||||||
|
|
|
@ -72,7 +72,8 @@ struct FunctionObjectOneIntOneChar
|
||||||
template<
|
template<
|
||||||
typename FunctorT,
|
typename FunctorT,
|
||||||
std::size_t Arity = 0,
|
std::size_t Arity = 0,
|
||||||
typename std::enable_if<rclcpp::arity_comparator<Arity, FunctorT>::value>::type * = nullptr
|
typename std::enable_if<
|
||||||
|
rclcpp::function_traits::arity_comparator<Arity, FunctorT>::value>::type * = nullptr
|
||||||
>
|
>
|
||||||
int func_accept_callback(FunctorT callback)
|
int func_accept_callback(FunctorT callback)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +83,7 @@ int func_accept_callback(FunctorT callback)
|
||||||
template<
|
template<
|
||||||
typename FunctorT,
|
typename FunctorT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::check_arguments<FunctorT, int>::value
|
rclcpp::function_traits::check_arguments<FunctorT, int>::value
|
||||||
>::type * = nullptr
|
>::type * = nullptr
|
||||||
>
|
>
|
||||||
int func_accept_callback(FunctorT callback)
|
int func_accept_callback(FunctorT callback)
|
||||||
|
@ -94,7 +95,7 @@ int func_accept_callback(FunctorT callback)
|
||||||
template<
|
template<
|
||||||
typename FunctorT,
|
typename FunctorT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::check_arguments<FunctorT, int, int>::value
|
rclcpp::function_traits::check_arguments<FunctorT, int, int>::value
|
||||||
>::type * = nullptr
|
>::type * = nullptr
|
||||||
>
|
>
|
||||||
int func_accept_callback(FunctorT callback)
|
int func_accept_callback(FunctorT callback)
|
||||||
|
@ -107,7 +108,7 @@ int func_accept_callback(FunctorT callback)
|
||||||
template<
|
template<
|
||||||
typename FunctorT,
|
typename FunctorT,
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
rclcpp::check_arguments<FunctorT, int, char>::value
|
rclcpp::function_traits::check_arguments<FunctorT, int, char>::value
|
||||||
>::type * = nullptr
|
>::type * = nullptr
|
||||||
>
|
>
|
||||||
int func_accept_callback(FunctorT callback)
|
int func_accept_callback(FunctorT callback)
|
||||||
|
@ -123,19 +124,19 @@ int func_accept_callback(FunctorT callback)
|
||||||
TEST(TestFunctionTraits, arity) {
|
TEST(TestFunctionTraits, arity) {
|
||||||
// Test regular functions
|
// Test regular functions
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(func_no_args)>::arity == 0,
|
rclcpp::function_traits::function_traits<decltype(func_no_args)>::arity == 0,
|
||||||
"Functor does not accept arguments");
|
"Functor does not accept arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(func_one_int)>::arity == 1,
|
rclcpp::function_traits::function_traits<decltype(func_one_int)>::arity == 1,
|
||||||
"Functor only accepts one argument");
|
"Functor only accepts one argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(func_two_ints)>::arity == 2,
|
rclcpp::function_traits::function_traits<decltype(func_two_ints)>::arity == 2,
|
||||||
"Functor only accepts two arguments");
|
"Functor only accepts two arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(func_one_int_one_char)>::arity == 2,
|
rclcpp::function_traits::function_traits<decltype(func_one_int_one_char)>::arity == 2,
|
||||||
"Functor only accepts two arguments");
|
"Functor only accepts two arguments");
|
||||||
|
|
||||||
// Test lambdas
|
// Test lambdas
|
||||||
|
@ -161,36 +162,36 @@ TEST(TestFunctionTraits, arity) {
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(lambda_no_args)>::arity == 0,
|
rclcpp::function_traits::function_traits<decltype(lambda_no_args)>::arity == 0,
|
||||||
"Functor does not accept arguments");
|
"Functor does not accept arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(lambda_one_int)>::arity == 1,
|
rclcpp::function_traits::function_traits<decltype(lambda_one_int)>::arity == 1,
|
||||||
"Functor only accepts one argument");
|
"Functor only accepts one argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(lambda_two_ints)>::arity == 2,
|
rclcpp::function_traits::function_traits<decltype(lambda_two_ints)>::arity == 2,
|
||||||
"Functor only accepts two arguments");
|
"Functor only accepts two arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<decltype(lambda_one_int_one_char)>::arity == 2,
|
rclcpp::function_traits::function_traits<decltype(lambda_one_int_one_char)>::arity == 2,
|
||||||
"Functor only accepts two arguments");
|
"Functor only accepts two arguments");
|
||||||
|
|
||||||
// Test objects that have a call operator
|
// Test objects that have a call operator
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<FunctionObjectNoArgs>::arity == 0,
|
rclcpp::function_traits::function_traits<FunctionObjectNoArgs>::arity == 0,
|
||||||
"Functor does not accept arguments");
|
"Functor does not accept arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<FunctionObjectOneInt>::arity == 1,
|
rclcpp::function_traits::function_traits<FunctionObjectOneInt>::arity == 1,
|
||||||
"Functor only accepts one argument");
|
"Functor only accepts one argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<FunctionObjectTwoInts>::arity == 2,
|
rclcpp::function_traits::function_traits<FunctionObjectTwoInts>::arity == 2,
|
||||||
"Functor only accepts two arguments");
|
"Functor only accepts two arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::function_traits<FunctionObjectOneIntOneChar>::arity == 2,
|
rclcpp::function_traits::function_traits<FunctionObjectOneIntOneChar>::arity == 2,
|
||||||
"Functor only accepts two arguments");
|
"Functor only accepts two arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,31 +203,35 @@ TEST(TestFunctionTraits, argument_types) {
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(func_one_int)>::template argument_type<0>
|
rclcpp::function_traits::function_traits<decltype(func_one_int)>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(func_two_ints)>::template argument_type<0>
|
rclcpp::function_traits::function_traits<decltype(func_two_ints)>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(func_two_ints)>::template argument_type<1>
|
rclcpp::function_traits::function_traits<decltype(func_two_ints)>::template argument_type<1>
|
||||||
>::value, "Functor accepts an int as second argument");
|
>::value, "Functor accepts an int as second argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(func_one_int_one_char)>::template argument_type<0>
|
rclcpp::function_traits::function_traits<
|
||||||
|
decltype(func_one_int_one_char)
|
||||||
|
>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
char,
|
char,
|
||||||
rclcpp::function_traits<decltype(func_one_int_one_char)>::template argument_type<1>
|
rclcpp::function_traits::function_traits<
|
||||||
|
decltype(func_one_int_one_char)
|
||||||
|
>::template argument_type<1>
|
||||||
>::value, "Functor accepts a char as second argument");
|
>::value, "Functor accepts a char as second argument");
|
||||||
|
|
||||||
// Test lambdas
|
// Test lambdas
|
||||||
|
@ -250,62 +255,70 @@ TEST(TestFunctionTraits, argument_types) {
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(lambda_one_int)>::template argument_type<0>
|
rclcpp::function_traits::function_traits<decltype(lambda_one_int)>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(lambda_two_ints)>::template argument_type<0>
|
rclcpp::function_traits::function_traits<decltype(lambda_two_ints)>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(lambda_two_ints)>::template argument_type<1>
|
rclcpp::function_traits::function_traits<decltype(lambda_two_ints)>::template argument_type<1>
|
||||||
>::value, "Functor accepts an int as second argument");
|
>::value, "Functor accepts an int as second argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<decltype(lambda_one_int_one_char)>::template argument_type<0>
|
rclcpp::function_traits::function_traits<
|
||||||
|
decltype(lambda_one_int_one_char)
|
||||||
|
>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
char,
|
char,
|
||||||
rclcpp::function_traits<decltype(lambda_one_int_one_char)>::template argument_type<1>
|
rclcpp::function_traits::function_traits<
|
||||||
|
decltype(lambda_one_int_one_char)
|
||||||
|
>::template argument_type<1>
|
||||||
>::value, "Functor accepts a char as second argument");
|
>::value, "Functor accepts a char as second argument");
|
||||||
|
|
||||||
// Test objects that have a call operator
|
// Test objects that have a call operator
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<FunctionObjectOneInt>::template argument_type<0>
|
rclcpp::function_traits::function_traits<FunctionObjectOneInt>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<FunctionObjectTwoInts>::template argument_type<0>
|
rclcpp::function_traits::function_traits<FunctionObjectTwoInts>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<FunctionObjectTwoInts>::template argument_type<1>
|
rclcpp::function_traits::function_traits<FunctionObjectTwoInts>::template argument_type<1>
|
||||||
>::value, "Functor accepts an int as second argument");
|
>::value, "Functor accepts an int as second argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
int,
|
int,
|
||||||
rclcpp::function_traits<FunctionObjectOneIntOneChar>::template argument_type<0>
|
rclcpp::function_traits::function_traits<
|
||||||
|
FunctionObjectOneIntOneChar
|
||||||
|
>::template argument_type<0>
|
||||||
>::value, "Functor accepts an int as first argument");
|
>::value, "Functor accepts an int as first argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_same<
|
std::is_same<
|
||||||
char,
|
char,
|
||||||
rclcpp::function_traits<FunctionObjectOneIntOneChar>::template argument_type<1>
|
rclcpp::function_traits::function_traits<
|
||||||
|
FunctionObjectOneIntOneChar
|
||||||
|
>::template argument_type<1>
|
||||||
>::value, "Functor accepts a char as second argument");
|
>::value, "Functor accepts a char as second argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,35 +328,35 @@ TEST(TestFunctionTraits, argument_types) {
|
||||||
TEST(TestFunctionTraits, check_arguments) {
|
TEST(TestFunctionTraits, check_arguments) {
|
||||||
// Test regular functions
|
// Test regular functions
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<decltype(func_one_int), int>::value,
|
rclcpp::function_traits::check_arguments<decltype(func_one_int), int>::value,
|
||||||
"Functor accepts a single int as arguments");
|
"Functor accepts a single int as arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::check_arguments<decltype(func_one_int), char>::value,
|
!rclcpp::function_traits::check_arguments<decltype(func_one_int), char>::value,
|
||||||
"Functor does not accept a char as argument");
|
"Functor does not accept a char as argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::check_arguments<decltype(func_one_int), char, int>::value,
|
!rclcpp::function_traits::check_arguments<decltype(func_one_int), char, int>::value,
|
||||||
"Functor does not accept two arguments");
|
"Functor does not accept two arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::check_arguments<decltype(func_two_ints), int>::value,
|
!rclcpp::function_traits::check_arguments<decltype(func_two_ints), int>::value,
|
||||||
"Functor does not accept a single int as argument, requires two ints");
|
"Functor does not accept a single int as argument, requires two ints");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<decltype(func_two_ints), int, int>::value,
|
rclcpp::function_traits::check_arguments<decltype(func_two_ints), int, int>::value,
|
||||||
"Functor accepts two ints as arguments");
|
"Functor accepts two ints as arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::check_arguments<decltype(func_two_ints), bool, int>::value,
|
!rclcpp::function_traits::check_arguments<decltype(func_two_ints), bool, int>::value,
|
||||||
"Functor does not accept a bool and an int as arguments, requires two ints");
|
"Functor does not accept a bool and an int as arguments, requires two ints");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::check_arguments<decltype(func_two_ints), int, char>::value,
|
!rclcpp::function_traits::check_arguments<decltype(func_two_ints), int, char>::value,
|
||||||
"Functor does not accept an int and a char as arguments, requires two ints");
|
"Functor does not accept an int and a char as arguments, requires two ints");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<decltype(func_one_int_one_char), int, char>::value,
|
rclcpp::function_traits::check_arguments<decltype(func_one_int_one_char), int, char>::value,
|
||||||
"Functor accepts an int and a char as arguments");
|
"Functor accepts an int and a char as arguments");
|
||||||
|
|
||||||
// Test lambdas
|
// Test lambdas
|
||||||
|
@ -365,28 +378,28 @@ TEST(TestFunctionTraits, check_arguments) {
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<decltype(lambda_one_int), int>::value,
|
rclcpp::function_traits::check_arguments<decltype(lambda_one_int), int>::value,
|
||||||
"Functor accepts an int as the only argument");
|
"Functor accepts an int as the only argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<decltype(lambda_two_ints), int, int>::value,
|
rclcpp::function_traits::check_arguments<decltype(lambda_two_ints), int, int>::value,
|
||||||
"Functor accepts two ints as arguments");
|
"Functor accepts two ints as arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<decltype(lambda_one_int_one_char), int, char>::value,
|
rclcpp::function_traits::check_arguments<decltype(lambda_one_int_one_char), int, char>::value,
|
||||||
"Functor accepts an int and a char as arguments");
|
"Functor accepts an int and a char as arguments");
|
||||||
|
|
||||||
// Test objects that have a call operator
|
// Test objects that have a call operator
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<FunctionObjectOneInt, int>::value,
|
rclcpp::function_traits::check_arguments<FunctionObjectOneInt, int>::value,
|
||||||
"Functor accepts an int as the only argument");
|
"Functor accepts an int as the only argument");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<FunctionObjectTwoInts, int, int>::value,
|
rclcpp::function_traits::check_arguments<FunctionObjectTwoInts, int, int>::value,
|
||||||
"Functor accepts two ints as arguments");
|
"Functor accepts two ints as arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::check_arguments<FunctionObjectOneIntOneChar, int, char>::value,
|
rclcpp::function_traits::check_arguments<FunctionObjectOneIntOneChar, int, char>::value,
|
||||||
"Functor accepts an int and a char as arguments");
|
"Functor accepts an int and a char as arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,27 +419,36 @@ TEST(TestFunctionTraits, same_arguments) {
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::same_arguments<decltype(lambda_one_int), decltype(func_one_int)>::value,
|
rclcpp::function_traits::same_arguments<
|
||||||
|
decltype(lambda_one_int), decltype(func_one_int)
|
||||||
|
>::value,
|
||||||
"Lambda and function have the same arguments");
|
"Lambda and function have the same arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::same_arguments<decltype(lambda_two_ints), decltype(func_one_int)>::value,
|
!rclcpp::function_traits::same_arguments<
|
||||||
|
decltype(lambda_two_ints), decltype(func_one_int)
|
||||||
|
>::value,
|
||||||
"Lambda and function have different arguments");
|
"Lambda and function have different arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::same_arguments<decltype(func_one_int_one_char), decltype(func_two_ints)>::value,
|
!rclcpp::function_traits::same_arguments<
|
||||||
|
decltype(func_one_int_one_char), decltype(func_two_ints)
|
||||||
|
>::value,
|
||||||
"Functions have different arguments");
|
"Functions have different arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
!rclcpp::same_arguments<decltype(lambda_one_int), decltype(lambda_two_ints)>::value,
|
!rclcpp::function_traits::same_arguments<
|
||||||
|
decltype(lambda_one_int), decltype(lambda_two_ints)
|
||||||
|
>::value,
|
||||||
"Lambdas have different arguments");
|
"Lambdas have different arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::same_arguments<FunctionObjectTwoInts, decltype(func_two_ints)>::value,
|
rclcpp::function_traits::same_arguments<FunctionObjectTwoInts, decltype(func_two_ints)>::value,
|
||||||
"Functor and function have the same arguments");
|
"Functor and function have the same arguments");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
rclcpp::same_arguments<FunctionObjectTwoInts, decltype(lambda_two_ints)>::value,
|
rclcpp::function_traits::same_arguments<
|
||||||
|
FunctionObjectTwoInts, decltype(lambda_two_ints)>::value,
|
||||||
"Functor and lambda have the same arguments");
|
"Functor and lambda have the same arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue