Skip to content

Commit

Permalink
Moved std::enable_if to template parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteve Fernandez committed Apr 30, 2015
1 parent 814f410 commit 639865d
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions rclcpp/include/rclcpp/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,20 @@ class Node
std::shared_ptr<rclcpp::service::ServiceBase> serv_base_ptr,
rclcpp::callback_group::CallbackGroup::SharedPtr group);

template<typename ServiceT, typename FunctorT>
typename std::enable_if<
function_traits<FunctorT>::arity == 2 &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<0>,
typename std::shared_ptr<typename ServiceT::Request>
>::value &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<1>,
typename std::shared_ptr<typename ServiceT::Response>
>::value,
typename rclcpp::service::Service<ServiceT>::SharedPtr>::type
template<
typename ServiceT,
typename FunctorT,
typename std::enable_if<
function_traits<FunctorT>::arity == 3 &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<0>,
typename std::shared_ptr<typename ServiceT::Request>
>::value &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<1>,
typename std::shared_ptr<typename ServiceT::Response>
>::value>::type * = nullptr>
typename rclcpp::service::Service<ServiceT>::SharedPtr
create_service_internal(
rmw_service_t * service_handle,
const std::string & service_name,
Expand All @@ -182,22 +184,24 @@ class Node
service_handle, service_name, callback_without_header);
}

template<typename ServiceT, typename FunctorT>
typename std::enable_if<
function_traits<FunctorT>::arity == 3 &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<0>,
std::shared_ptr<rmw_request_id_t>
>::value &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<1>,
typename std::shared_ptr<typename ServiceT::Request>
>::value &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<2>,
typename std::shared_ptr<typename ServiceT::Response>
>::value,
typename rclcpp::service::Service<ServiceT>::SharedPtr>::type
template<
typename ServiceT,
typename FunctorT,
typename std::enable_if<
function_traits<FunctorT>::arity == 3 &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<0>,
std::shared_ptr<rmw_request_id_t>
>::value &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<1>,
typename std::shared_ptr<typename ServiceT::Request>
>::value &&
std::is_same<
typename function_traits<FunctorT>::template argument_type<2>,
typename std::shared_ptr<typename ServiceT::Response>
>::value>::type * = nullptr>
typename rclcpp::service::Service<ServiceT>::SharedPtr
create_service_internal(
rmw_service_t * service_handle,
const std::string & service_name,
Expand Down

0 comments on commit 639865d

Please sign in to comment.