manpagez: man pages & more
info ginac
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.1 Note: Expressions and STL containers

GiNaC expressions (ex objects) have value semantics (they can be assigned, reassigned and copied like integral types) but the operator < doesn't provide a well-defined ordering on them. In STL-speak, expressions are ‘Assignable’ but not ‘LessThanComparable’.

This implies that in order to use expressions in sorted containers such as std::map<> and std::set<> you have to supply a suitable comparison predicate. GiNaC provides such a predicate, called ex_is_less. For example, a set of expressions should be defined as std::set<ex, ex_is_less>.

Unsorted containers such as std::vector<> and std::list<> don't pose a problem. A std::vector<ex> works as expected.

See section Getting information about expressions, for more about comparing and ordering expressions.


© manpagez.com 2000-2024
Individual documents may contain additional copyright information.