Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rclcpp/include/rclcpp/function_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ template<typename ClassT, typename ReturnTypeT, typename ... Args, typename ...
#if defined _LIBCPP_VERSION // libc++ (Clang)
struct function_traits<std::__1::__bind<ReturnTypeT (ClassT::*)(Args ...), FArgs ...>>
#elif defined _GLIBCXX_RELEASE // glibc++ (GNU C++ >= 7.1)
struct function_traits<std::_Bind<ReturnTypeT(ClassT::*(ClassT *, FArgs ...))(Args ...)>>
struct function_traits<std::_Bind<ReturnTypeT(ClassT::*(FArgs ...))(Args ...)>>
#elif defined __GLIBCXX__ // glibc++ (GNU C++)
struct function_traits<std::_Bind<std::_Mem_fn<ReturnTypeT (ClassT::*)(Args ...)>(FArgs ...)>>
#elif defined _MSC_VER // MS Visual Studio
Expand Down
20 changes: 20 additions & 0 deletions rclcpp/test/test_function_traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,23 @@ TEST(TestFunctionTraits, sfinae_match) {

EXPECT_EQ("foo", func_accept_callback_return_type(lambda_no_args_string));
}

class TestMember : public ::testing::Test
{
public:
void MemberFunctor(int, float, std::string) {}
};

/*
Regression test for https://github.com/ros2/rclcpp/issues/479, specific to classes using the
TEST_F GTest macro.
*/
TEST_F(TestMember, bind_member_functor) {
auto bind_member_functor = std::bind(&TestMember::MemberFunctor, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);

static_assert(
rclcpp::function_traits::check_arguments<decltype(bind_member_functor), int, float,
std::string>::value,
"Functor accepts an int, a float and a string as arguments");
}