liam-middlebrook / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Assignment operator unexpected result on const Objects #285

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I wrote a code like this:

const YAML::Node mynode = root;
for(string key: mypath)
{
  mynode = mynode[key];
}

I expect to follow the graph. But it does not work, the root object is modified 
assigning the value of it's subkey.

I noticed that the assignment operator is declared and it changes the values, 
but for const objects I don't expect this behaviour.

I'm using yaml-cpp 0.5.1 with new API

Original issue reported on code.google.com by lucamart...@gmail.com on 19 Mar 2015 at 10:47

GoogleCodeExporter commented 9 years ago
Yeah, this is an example of some of the unintuitive behavior in the new API. 
I'm not sure exactly what to do with it - I'm merging this issue into the main 
one for this kind of behavior.

Original comment by jbe...@gmail.com on 20 Mar 2015 at 3:59

GoogleCodeExporter commented 9 years ago
I'm sorry, I misread this when I first looked. Does what you're writing even 
compile? There's no overload for operator= with a const YAML::Node.

Original comment by jbe...@gmail.com on 21 Mar 2015 at 4:40