Boost logo

Boost :

From: Dominic Herity (dominic.herity_at_[hidden])
Date: 2005-05-26 18:16:19

I've often wished that STL sets supported set arithmetic operations.
Addition, multiplication and subtraction operators could be overloaded with
set union, intersection and difference respectively.

For example:
            set<char> s1; // s1 <- {}
            s1 += 'a'; // s1 <- {a}
            set<char> s2 = s1 + 'b'; // s2 <- {a,b}
            set<char> s3 = s2 - s1; // s3 <- {b}
            set<char> s4 = s1 * s2; // s4 <- {a}

Achieving the above results with the existing STL library is by comparison
cumbersome, error-prone and unclear.

Although this proposal does not follow the STL design philosophy, it meets a
real developer need. It can be implemented using global operator overloads,
which should avoid conflicts with other uses of STL sets.

Comments and suggestions welcome.

Best Regards
Dominic Herity
Red Plain Technology (
T:+353-87-2208233 F: +1-603-909 6570 E: dominic.herity_at_[hidden]

Boost list run by bdawes at, gregod at, cpdaniel at, john at