Ask Your Question
0

Using std::vector Copy Constructor In a Message

asked 2011-10-25 08:01:53 -0500

Constantin S gravatar image

updated 2011-10-25 09:54:34 -0500

Hello all, I am attempting the following code:

vector<float> ranges(360, 10); //A vector of 360 '10's
sensor_msgs::LaserScan currentScan;
currentScan.ranges(ranges);   // <---------- Fails

Here is the cryptic error message:

error: no match for call to ‘(std::vector<float, std::allocator<float> >) (std::vector<float,std::allocator<float> >&)’

I tried googling similar errors but to no avail. If someone could offer some readings on the failure behind this, I would really appreciate this. Thank you

Constantin

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
5

answered 2011-10-25 08:09:55 -0500

Mac gravatar image

You can't use copy-constructor syntax because currentScan.ranges has already been constructed (as part of the constructor for sensor_msgs::LaserScan).

Assignment will work, though:

currentScan.ranges = ranges;
edit flag offensive delete link more

Comments

Ahh of course. Thank you!
Constantin S gravatar image Constantin S  ( 2011-10-25 09:54:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-10-25 08:01:53 -0500

Seen: 1,201 times

Last updated: Oct 25 '11