Hi,


I have an expression tree in which the nodes are operators (union, intersection etc represented by a string "/u") or the nodes are std::sets.

How could I access the std::set's values in order to carry out the tree evaluation using the operator functions(set_union(), set_intersection() etc) ? The expressions are pre and postfix.

Thanks for any help, it's most appreciated.

Recommended Answers

All 3 Replies

Use begin() and end() the way you would for any other container.

Thanks for your help, so you think I should implement my tree_evaluation() function to iterate through the sets, and return the values held to the set_union(), set_intersection() functions?


Thanks for giving me direction with this. I'm new to trees in general. :)

Well... set_union and set_intersection are really intended to let you do set operations on sorted vectors. Curiously, they don't work if the destination is an actual set. So you have to implement those operations yourself using insert and erase, which, fortunately, aren't particularly different operations.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.