-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
If you add values along a multi-level path to the ptree, the values of the intermediate nodes remain uninitialized. The sample code is below
#include <boost/property_tree/ptree.hpp>
#include <iostream>
enum class NodeType
{
Intermediate,
Root,
Leaf
};
using Tree = boost::property_tree::basic_ptree<std::string, NodeType>;
void Print(const Tree& tree, std::string_view name)
{
const auto value = tree.get_value(NodeType::Intermediate);
std::cout << "Name: " << name << ", value: " << static_cast<int>(value) << std::endl;
for (const auto& [childName, subtree]: tree)
Print(subtree, childName);
}
int main() {
Tree tree;
tree.add("Intermediate1.Intermediate2.Leaf", NodeType::Leaf);
tree.put_value(NodeType::Root);
Print(tree, "Root");
}Compiled with boost 1.87 by x86-64 clang-18.1.0
Godbolt link
Possible output:
Name: Root, value: 1
Name: Intermediate1, value: 0
Name: Intermediate2, value: -249048016
Name: Leaf, value: 2
One of the correction options https://github.com/ilya-talankin/property_tree/pull/1/files
Metadata
Metadata
Assignees
Labels
No labels