Closed GoogleCodeExporter closed 9 years ago
if possible, please publish a patch asap, the timing of this bug is a bit
inconvenient.
Original comment by nev...@gmail.com
on 6 Jun 2013 at 11:02
This is intended behavior. You're modifying the existing node. Specifically,
consider:
YAML::Node doc = YAML::Load("{a: 1, b: 2}");
YAML::Node a = doc["a"];
a = doc["b"];
The third line is semantically the same as
doc["a"] = doc["b"];
In the new API, yaml-cpp treats = as setting identity. The result is that the
document now looks like
b: &x 2
a: *x
Note that you're not getting a "crash"; instead, it's throwing an exception,
saying that it can't convert the given value to a boolean. This is because
you've modified the document.
Instead, you want to use reset(). E.g.:
k.reset(node["test_parm"]);
Original comment by jbe...@gmail.com
on 7 Jun 2013 at 9:13
OK thanks for that clarification... I have to say this while intended was
not intuitive... at this point Nodes look like an invasively fused smart
pointer and an object which may give some conveniences (where?) but differ
in behavior from either..
In any case, am I missing some explanations of this somewhere? Are the
docs up to date regarding these new details?
Original comment by nev...@gmail.com
on 7 Jun 2013 at 9:35
Yeah, I agree, this is a corner case that's not intuitive. I'm really not sure
if it's the right behavior; I'm trying to mimic python syntax, but C++ doesn't
make that easy.
I'll look into updating the docs, and I'll continue thinking about this
behavior more. Thanks for the note.
Original comment by jbe...@gmail.com
on 7 Jun 2013 at 9:38
I created an issue to track modifying this behavior, so you'll be updated if I
can figure out what to do.
Original comment by jbe...@gmail.com
on 7 Jun 2013 at 9:41
Original issue reported on code.google.com by
nev...@gmail.com
on 6 Jun 2013 at 11:00Attachments: