# Operators
[Fundamental C++: the Element design pattern.]

Collaboration diagram for Operators:

## Classes

struct | op_add_traits< S1, S2, T1, T2 >
| The type of the result of addition between two Element instances. More...
struct | op_sub_traits< S1, S2, T1, T2 >
| The type of the result of substraction between two Element instances. More...
struct | op_mul_traits< S1, S2, T1, T2 >
| The type of the result of multiplication between two Element instances. More...
struct | op_div_traits< S1, S2, T1, T2 >
| The type of the result of division between two Element instances. More...
struct | op_mod_traits< S1, S2, T1, T2 >
| The type of the result of modulus between two Element instances. More...

## Files

file | default_ops.hh

| Default implementations for standard `Element` operations.
file | element_op_traits.hh

| Declaration of default arithmetical operator traits for `Element`.
file | element_ops.hh

| Declarations of standard external operator delegations for `Element`.

## Functions

template<typename S , typename T >
bool | op_contains (const Structure< S > &set, const T &value)
| Check whether a value is contained in a set.
template<typename S , typename T , typename U >
bool | op_eq (const Structure< S > &, const T &v1, const U &v2)
| Equality between two structured values.
template<typename S , typename V , typename T , typename U >
bool | op_eq (const Structure< S > &, const Structure< V > &, const T &v1, const U &v2)
| Equality between two structured values.
template<typename S , typename T , typename U >
bool | op_lt (const Structure< S > &, const T &v1, const U &v2)
| Ordered comparison between two structured values.
template<typename S , typename V , typename T , typename U >
bool | op_lt (const Structure< S > &, const Structure< V > &, const T &v1, const U &v2)
| Ordered comparison between two structured values.
template<typename S , typename R , typename T >
R | op_convert (const Structure< S > &se, SELECTOR(R), const T &data)
| Default conversion between value types with computation.
template<typename S , typename T >
const T & | op_convert (const Structure< S > &se, SELECTOR(T), const T &from_data)
| Pass-through conversion.
template<typename S , typename T >
const T & | op_convert (const Structure< S > &se, SELECTOR(T), const Structure< S > &from_se, const T &from_data)
| Pass-through conversion between compatible structures.
template<typename S , typename T >
T | op_default (const Structure< S > &se, SELECTOR(T))
| Default construction of values using `Structure`.
template<typename S , typename T >
void | op_swap (const Structure< S > &se, T &v1, T &v2)
| Default swap operator.
template<typename S , typename T , typename U >
void | op_assign (const Structure< S > &s, T &dst, const U &src)
| Assignement operator between two implementations of a Structure<S>.
template<typename S , typename T , typename U >
void | op_assign (const Structure< S > &s1, const Structure< S > &s2, T &dst, const U &src)
| Assignement operator between two implementations of two differents structures.
template<typename S , typename T , typename U >
void | op_in_add (const Structure< S > &s1, const Structure< S > &s2, T &dst, const U &arg)
| Addition in place operator between two different elements.
template<typename S , typename T , typename U >
void | op_in_sub (const Structure< S > &s1, const Structure< S > &s2, T &dst, const U &arg)
| Substraction in place operator between two different elements.
template<typename S , typename T , typename U >
void | op_in_mul (const Structure< S > &s1, const Structure< S > &s2, T &dst, const U &arg)
| Multiplication in place operator between two different elements.
template<typename S , typename T , typename U >
void | op_in_div (const Structure< S > &s1, const Structure< S > &s2, T &dst, const U &arg)
| Division in place operator between two different elements.
template<typename S , typename T , typename U >
void | op_in_mod (const Structure< S > &s1, const Structure< S > &s2, T &dst, const U &arg)
| Modulo in place operator between two different elements.
template<typename S , typename T , typename U >
T | op_add (const Structure< S > &s1, const Structure< S > &s2, const T &v1, const U &v2)
| Addition operator between two different elements.
template<typename S , typename T , typename U >
T | op_sub (const Structure< S > &s1, const Structure< S > &s2, const T &v1, const U &v2)
| Substraction operator between two different elements.
template<typename S , typename T , typename U >
T | op_mul (const Structure< S > &s1, const Structure< S > &s2, const T &v1, const U &v2)
| Multiplication operator between two different elements.
template<typename S , typename T , typename U >
T | op_div (const Structure< S > &s1, const Structure< S > &s2, const T &v1, const U &v2)
| Division operator between two different elements.
template<typename S , typename T , typename U >
T | op_mod (const Structure< S > &s1, const Structure< S > &s2, const T &v1, const U &v2)
| Modulo operator between two different elements.
template<typename S , typename St , typename T >
St & | op_rin (const Structure< S > &s, St &st, const T &v)
| Input stream operator.
template<typename S , typename St , typename T >
St & | op_rout (const Structure< S > &s, St &st, const T &v)
| Output stream operator.
template<typename S1 , typename T1 , typename S2 , typename T2 >
static bool | operator< (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Comparison between Element instances.
template<typename S1 , typename T1 , typename S2 , typename T2 >
static bool | operator> (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Comparison between Element instances.
template<typename S1 , typename T1 , typename S2 , typename T2 >
static bool | operator<= (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Comparison between Element instances.
template<typename S1 , typename T1 , typename S2 , typename T2 >
static bool | operator>= (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Comparison between Element instances.
template<typename S , typename T , typename U >
static bool | operator< (const vcsn::Element< S, T > &e, const U &v)
| Comparison between Element and foreign values (left version).
template<typename S , typename T , typename U >
static bool | operator> (const vcsn::Element< S, T > &e, const U &v)
| Comparison between Element and foreign values (left version).
template<typename S , typename T , typename U >
static bool | operator>= (const vcsn::Element< S, T > &e, const U &v)
| Comparison between Element and foreign values (left version).
template<typename S , typename T , typename U >
static bool | operator<= (const vcsn::Element< S, T > &e, const U &v)
| Comparison between Element and foreign values (left version).
template<typename U , typename S , typename T >
static bool | operator< (const U &v, const vcsn::Element< S, T > &e)
| Comparison between Element and foreign values (right version).
template<typename U , typename S , typename T >
static bool | operator> (const U &v, const vcsn::Element< S, T > &e)
| Comparison between Element and foreign values (right version).
template<typename U , typename S , typename T >
static bool | operator>= (const U &v, const vcsn::Element< S, T > &e)
| Comparison between Element and foreign values (right version).
template<typename U , typename S , typename T >
static bool | operator<= (const U &v, const vcsn::Element< S, T > &e)
| Comparison between Element and foreign values (right version).
template<typename S1 , typename T1 , typename S2 , typename T2 >
static bool | operator== (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Equality between Element instances.
template<typename S , typename T , typename U >
static bool | operator== (const vcsn::Element< S, T > &e, const U &v)
| Equality between Element and foreign values (left version).
template<typename U , typename S , typename T >
static bool | operator== (const U &v, const vcsn::Element< S, T > &e)
| Equality between Element and foreign values (right version).
template<typename S1 , typename T1 , typename S2 , typename T2 >
static bool | operator!= (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Difference between Element instances.
template<typename S , typename T , typename U >
static bool | operator!= (const vcsn::Element< S, T > &e, const U &v)
| Difference between Element and foreign values (left version).
template<typename U , typename S , typename T >
static bool | operator!= (const U &v, const vcsn::Element< S, T > &e)
| Difference between Element and foreign values (right version).
template<typename S1 , typename T1 , typename S2 , typename T2 >
static vcsn::op_add_traits< S1, S2, T1, T2 >::ret_t | operator+ (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Addition between Element instances.
template<typename S , typename T , typename U >
static vcsn::Element< S, T > | operator+ (const vcsn::Element< S, T > &e, const U &v)
| Addition between Element and foreign values (left).
template<typename U , typename S , typename T >
static vcsn::Element< S, T > | operator+ (const U &v, const vcsn::Element< S, T > &e)
| Addition between Element and foreign values (right).
template<typename S1 , typename T1 , typename S2 , typename T2 >
static vcsn::op_sub_traits< S1, S2, T1, T2 >::ret_t | operator- (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Substraction between Element instances.
template<typename S , typename T , typename U >
static vcsn::Element< S, T > | operator- (const vcsn::Element< S, T > &e, const U &v)
| Substraction between Element and foreign values (left).
template<typename U , typename S , typename T >
static vcsn::Element< S, T > | operator- (const U &v, const vcsn::Element< S, T > &e)
| Substraction between Element and foreign values (right).
template<typename S1 , typename T1 , typename S2 , typename T2 >
static vcsn::op_mul_traits< S1, S2, T1, T2 >::ret_t | operator* (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Multiplication between Element instances.
template<typename S , typename T , typename U >
static vcsn::Element< S, T > | operator* (const vcsn::Element< S, T > &e, const U &v)
| Multiplication between Element and foreign values (left).
template<typename U , typename S , typename T >
static vcsn::Element< S, T > | operator* (const U &v, const vcsn::Element< S, T > &e)
| Multiplication between Element and foreign values (right).
template<typename S1 , typename T1 , typename S2 , typename T2 >
static vcsn::op_div_traits< S1, S2, T1, T2 >::ret_t | operator/ (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Division between Element instances.
template<typename S , typename T , typename U >
static vcsn::Element< S, T > | operator/ (const vcsn::Element< S, T > &e, const U &v)
| Division between Element and foreign values (left).
template<typename U , typename S , typename T >
static vcsn::Element< S, T > | operator/ (const U &v, const vcsn::Element< S, T > &e)
| Division between Element and foreign values (right).
template<typename S1 , typename T1 , typename S2 , typename T2 >
static vcsn::op_mod_traits< S1, S2, T1, T2 >::ret_t | operator% (const vcsn::Element< S1, T1 > &e1, const vcsn::Element< S2, T2 > &e2)
| Modulus between Element instances.
template<typename S , typename T , typename U >
static vcsn::Element< S, T > | operator% (const vcsn::Element< S, T > &e, const U &v)
| Modulus between Element and foreign values (left).
template<typename U , typename S , typename T >
static vcsn::Element< S, T > | operator% (const U &v, const vcsn::Element< S, T > &e)
| Modulus between Element and foreign values (right.
template<typename S , typename T >
static vcsn::Element< S, T > | operator- (const vcsn::Element< S, T > &)
| Unary negation of Element instances.
template<typename St , typename S , typename T >
static St & | operator<< (St &s, const vcsn::Element< S, T > &e)
| Output to stream.
template<typename St , typename S , typename T >
static St & | operator>> (St &s, const vcsn::Element< S, T > &e)
| Input from stream.
template<typename S , typename T1 , typename T2 >
void | swap (vcsn::Element< S, T1 > &e1, vcsn::Element< S, T2 > &e2)
| Swap to Element instances with the same structure.
template<typename S , typename T >
void | swap (vcsn::Element< S, T > &e1, T &v2)
| Swap between Element and foreign values (left).
template<typename T , typename S >
void | swap (T &v1, vcsn::Element< S, T > &e2)
| Swap between Element and foreign values (right).

## Inequality operator for Structures.

Calls equality operator of sub-class.
template<typename S >
bool | operator!= (const vcsn::Structure< S > &a, const vcsn::Structure< S > &b)

## Function Documentation

bool op_contains | ( | const Structure< S > & | set,
|  | const T & | value |
| ) |  |  |

Check whether a value is contained in a set.

`op_contains` is an operator appliable on every structure; this is the "is in" relation.

Definition at line 31 of file default_ops.hxx.

Referenced by Structure< S >::contains().

void swap | ( | vcsn::Element< S, T1 > & | e1,
|  | vcsn::Element< S, T2 > & | e2 |
| ) |  |  |

Swap to Element instances with the same structure.

Calling this operators is valid only if the structural elements of the two Element instances are equal.

Definition at line 227 of file element_ops.hxx.

References vcsn::op_swap(), Element< S, T >::structure(), and Element< S, T >::value().

Referenced by vcsn::confirm_and_report_match(), vcsn::algebra::ext_gcd(), vcsn::op_swap(), and vcsn::window_backsearch().

bool operator!= | ( | const vcsn::Structure< S > & | a,
|  | const vcsn::Structure< S > & | b |
| ) |  |  |

Definition at line 103 of file structure.hxx.

References Structure< S >::self().