Libzypp/Design/Relation/Operator

< Libzypp‎ | Design‎ | Relation
Şuraya atla: kullan, ara

Relational operators

Relational operators are now named:

Rel::EQ
Rel::NE
Rel::LT
...

Rel is used the same way as if it was an enum

Rel opvar;
opvar = Rel::LT;

Only if you use it in a switch statement, it's a bit different. Code example is in docs.

Plus:

  • Rel is constructible from a string (throws on illegal value)
Rel opvar( "==" );
Rel opvar( "EQ" );
Rel opvar( "eq" );
  • Conversion into string via asString(). Uses the "==" form.
  • Wrapped in a namespace (Rel::EQ not simply EQ) it prevents name clashes.
  • No promotion to numerical types (as the compiler does for enum values). I.e. you can't use it as int, and the compiler can't do it either.


back

Last edit in Trac '11/23/05 10:49:55' by 'kkaempf'


Last edit in Trac '11/23/05 10:49:55' by 'kkaempf'


Last edit in Trac '11/23/05 10:49:55' by 'kkaempf'


Last edit in Trac '11/23/05 10:49:55' by 'kkaempf'


Last edit in Trac '11/23/05 10:49:55' by 'kkaempf'