From be295fb5e60d42767db0dde2a3c693ce86f95e42 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Thu, 4 Sep 2003 18:31:09 +0000 Subject: [PATCH] added a note about expressions in STL containers --- doc/tutorial/ginac.texi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index dfaf6453..d07518ef 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -721,6 +721,25 @@ The next sections will outline the general picture of GiNaC's class hierarchy and describe the classes of objects that are handled by @code{ex}. +@subsection Note: Expressions and STL containers + +GiNaC expressions (@code{ex} objects) have value semantics (they can be +assigned, reassigned and copied like integral types) but the operator +@code{<} doesn't provide a well-defined ordering on them. In STL-speak, +expressions are @samp{Assignable} but not @samp{LessThanComparable}. + +This implies that in order to use expressions in sorted containers such as +@code{std::map<>} and @code{std::set<>} you have to supply a suitable +comparison predicate. GiNaC provides such a predicate, called +@code{ex_is_less}. For example, a set of expressions should be defined +as @code{std::set}. + +Unsorted containers such as @code{std::vector<>} and @code{std::list<>} +don't pose a problem. A @code{std::vector} works as expected. + +@xref{Information About Expressions}, for more about comparing and ordering +expressions. + @node Automatic evaluation, Error handling, Expressions, Basic Concepts @c node-name, next, previous, up -- 2.44.0