ScalarExpression concept

Description

A scalar expression is an expression which after computation results in a scalar. Thus a scalar expression can be assigned to a scalar (relying on a conversion if necessary).

Refinement of

Expression.

Associated types

Those of Expression.

Notation

X Type that is a model of ScalarExpression
C Type so that X is convertible to C
a Objects of type X
c Object of type C

Definitions

Valid expressions

In addition to those of Expression:
Name Expression Type requirements Return type
ConversionAssignment c=a C
ConversionConstructor C c(a) C

ScalarExpression semantics

In addition to those of Expression:
Name Expression Precondition Semantics Postcondition
ConversionAssignment [1] c=a Returns the value of the expression
ConversionConstructor [1] C c(a) Returns the value of the expression

Complexity guarantees

Invariants

Models

Notes

[1] Generally any scalar-expression will have to implement a templated conversion operator ('template <class T> T operator() const') to allow this conversion. Scalars are different in respect to vector and matrices because it is not possible to add an assignment operator to the builtin types (scalars) that accept a scalar-expression. One can argue that it is neither possible to add an assignment operator to std::vector and thus an implicit conversion operator should be foreseen for vector-expressions too. The drawback however would be that this would be very inefficient for vectors to return them by value and thus an assign is thus far superior anyway.