The file offers a few handy functions on standard C++ containers
out << Loutput elements of
L(as comma separated list in square brackets)
product(L)returns the product of the entries of
L; gives error if
sum(L)returns the sum of the entries of
L; gives error if
HasUniqueOwner(L)returns true if the entries of
Lall have the same owner; gives error if
LexCmp3(begin1,end1, begin2,end2)do a 3-way lex comparison; returns <0,=0,>0 according as first seq is <,=,> second seq. Uses
cmpbetween elements, and assumes
The output functions are specifically only for
I cannot make it more general without ambiguities arising.
The implementations of the printing functions could hardly be simpler.
The only "clever" part is the fn
OutputRange which actually does the work.
Implemented as template code in the header file.
The implementation is slightly indirect to allow use of
(also so that would work with lists/vectors/etc)
OutputRange is publicly visible, but is not intended for public use.
product is a bit too complicated.
Need a template expert to clean it.
Perhaps add also a
LexCmp3 that takes complete containers?
Currently it is "STL compatible" (which I think is usually awkward).
It would make the calls in
Activate the commented out template fn
int seemed the most natural choice for the return value of this
three-way comparison functions (though
signed char would be big enough).
The implementation assumes that
operator< is defined; this decision was
inspired by assumptions made by various STL functions. The types of the
arguments may be different as this is probably be more convenient for the
user. Obviously the generic definition given here can be overridden by
more efficient specific definitions for certain argument types.