[ros-users] [Discourse.ros.org] [Next Generation ROS] RFC: u…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Morgan Quigley via ros-users
Date:  
To: ros-users
Subject: [ros-users] [Discourse.ros.org] [Next Generation ROS] RFC: using C++14



This is only tangentially related to the question of "should we use C++14", but anyway this is an attempt to simplify the minimal examples using generic lambas:

For example, this C++11 code:

    subscription_ = this->create_subscription<std_msgs::msg::String>(
      "topic",
      [](std_msgs::msg::String::UniquePtr msg) {
      printf("I heard: [%s]\n", msg->data.c_str());
    });


requires the message type to be listed twice: once for the create_subscription<> template, and once for the lambda parameter. It would be nice if we could do this:

    subscription_ = this->create_subscription<std_msgs::msg::String>(
      "topic", [](auto msg) {
      printf("I heard: [%s]\n", msg->data.c_str());
    });


However, that code change explodes spectacularly into a few hundred lines of gcc errors.

Does anybody know if that style of usage (mixing generic lambas with template instantiations) is just impossible in C++14 ? The overlap between lambdas and templates still seems a bit mysterious to me.






---
[Visit Topic](https://discourse.ros.org/t/rfc-using-c-14/921/9) or reply to this email to respond.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list

http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>