{ "format": 1, "id": "saw-branch", "kind": "class", "name": "branch", "namespace": "saw", "module": "core", "header": "modules/core/c++/tree.hpp", "brief_description": "Container with a simplistic approach to a branch.", "detailed_description": [ [ "The edge in a", {"name": "tree_container", "id": "saw-tree_container"}, "It holds either a leaf value or a whole sub tree, as a variant of the two, so the recursion lives in the data rather than in a pointer chain." ], [ "Access comes in two flavours: get asserts what is held, while extract and replace hand the content out or swap it and report a mismatch as an error instead." ] ], "templates": [ {"name": "T", "kind": "type", "brief_description": "Leaf value type."}, {"name": "Tree", "kind": "type", "brief_description": "Sub tree type."} ], "aliases": { "saw-branch-type": { "id": "saw-branch-type", "name": "type", "type": ["std::variant< Tree, T >"], "brief_description": "Either a sub tree or a leaf." } }, "functions": { "saw-branch-is": { "id": "saw-branch-is", "name": "is", "type": ["bool"], "const": true, "brief_description": "Whether the branch holds the given alternative.", "templates": [ {"name": "NT", "kind": "type"} ] }, "saw-branch-is_tree": { "id": "saw-branch-is_tree", "name": "is_tree", "type": ["bool"], "const": true, "brief_description": "Whether the branch continues into a sub tree." }, "saw-branch-is_value": { "id": "saw-branch-is_value", "name": "is_value", "type": ["bool"], "const": true, "brief_description": "Whether the branch ends in a leaf." }, "saw-branch-get_tree": { "id": "saw-branch-get_tree", "name": "get_tree", "type": ["Tree &"], "brief_description": "The sub tree. Only valid if is_tree." }, "saw-branch-get_value": { "id": "saw-branch-get_value", "name": "get_value", "type": ["T &"], "brief_description": "The leaf. Only valid if is_value." }, "saw-branch-extract_tree": { "id": "saw-branch-extract_tree", "name": "extract_tree", "type": ["error_or< Tree >"], "brief_description": "Takes the sub tree out, failing if the branch holds a leaf." }, "saw-branch-extract_value": { "id": "saw-branch-extract_value", "name": "extract_value", "type": ["error_or< T >"], "brief_description": "Takes the leaf out, failing if the branch holds a sub tree." }, "saw-branch-replace_tree": { "id": "saw-branch-replace_tree", "name": "replace_tree", "type": ["error_or< Tree >"], "brief_description": "Swaps in new content and returns the sub tree which was there.", "parameters": [ {"name": "nd", "type": ["type"]} ] }, "saw-branch-replace_value": { "id": "saw-branch-replace_value", "name": "replace_value", "type": ["error_or< T >"], "brief_description": "Swaps in new content and returns the leaf which was there.", "parameters": [ {"name": "nd", "type": ["type"]} ] } }, "notes": [ "Copy is forbidden, move is allowed." ] }